Questions tagged [angularjs-ng-init]

In AngularJS, the ngInit directive allows you to evaluate an expression in the current scope.

From Angularjs documentation:

The ngInit directive allows you to evaluate an expression in the current scope.
The only appropriate use of ngInit is for aliasing special properties of ngRepeat. Besides this case, you should use controllers rather than ngInit to initialize values on a scope.

Note: If you have assignment in ngInit along with $filter, make sure you have parenthesis for correct precedence:

<div ng-init="test1 = (data | orderBy:'name')"></div>

Usage

as attribute:

<ANY
  ng-init="expression">
...
</ANY>

as CSS class:

<ANY class="ng-init: expression;"> ... </ANY>
135 questions
1
vote
0 answers

Trigger ng-init manually

I have a profile with a series of cards. Each card has a type (e.g. gallery card, quote card, etc) and the profile can have 1 or more of each type. I'm building a profile editor and want to be able to open an edit form in a modal. Each card has its…
Daniel Bonnell
  • 4,817
  • 9
  • 48
  • 88
1
vote
2 answers

AngularJs assign http response object to scope from html

This is the first time I use AngularJs and I would really appreciate some help on this. I have a json file from which I am retrieving some content that gets displayed on my html template. So far so good. I need to assign an http response data to the…
Jeff
  • 543
  • 2
  • 9
  • 27
1
vote
1 answer

ng-init not working with sails.get("/..")

I am trying to use ng-init to initialize values for each item in my ng-repeat. Each ng-repeat iteration calls a method which then does a sails.get call to get info from the db about the specific item, which should show the data in my view. Is there…
cfl
  • 999
  • 1
  • 14
  • 34
1
vote
1 answer

AngularJS: array[ {{value}} ] causes a parse error that I want to ignore

I have a selection list that I get from the controller, written like this:
1
vote
1 answer

How to let Angular JS ng-init only under certain condition?

Let say I have the following short input form:
cytsunny
  • 4,838
  • 15
  • 62
  • 129
1
vote
1 answer

how to avoid ng-init after first initialization

im using ng-init in my app to initalize a variable. problem is i am changing this variable after app is loaded and i want the variable i first initialized to store new value after function executes. im new to angular and couldn't figure it…
Al.s
  • 300
  • 4
  • 20
1
vote
1 answer

Radiobuttons ng-checked not displaying div by default and works only onclick

I'm new to web development with Angular js. I'm trying to show and hide a textbox inside a div using class. I have two radio buttons "Yes" and "No". So, I'm trying to show the div containing the textbox when I click on Yes and hide when I click on…
1
vote
2 answers

Mathematical operations on ng init

I am trying to do mathematical operations of ng init
Out put in the format of aaa1 But it does not work.
Patan
  • 17,073
  • 36
  • 124
  • 198
1
vote
1 answer

Ng-include: access child models

I have a template which I want to use in many parts of my application. The template contains select box with a model assigned. I include the template by the means of ng-include.
1
vote
1 answer

How do a grab a DOM element as soon as it has been loaded

I'm working on an angular application that uses ng-grid through out on one of the grids I have a cell template with an ng-init function attached to one of it's dom elements. var cellTemplate = '
Working Title
  • 254
  • 7
  • 28
1
vote
2 answers

ng-init and ng-options html str issue angularjs

I have to dynamically create a select list in angularjs directive. I have double quote ng-init and ng-options, using angular.element to create the element and append to a div with id preview. the code looks like…
eded
  • 3,778
  • 8
  • 28
  • 42
1
vote
1 answer

how to fill combo box on page load in angular js?

I have a page which has two combobox in it. This is my view :
1 2 3
8 9