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
2 answers

Passing ASP.Net MVC controller/actions in Angular

I've been searching the web, but can't seem to find a good answer on this... Is this the correct way to pass a controller/action URL to Angular?
or is…
Scottie
  • 11,050
  • 19
  • 68
  • 109
1
vote
1 answer

How to define a data with accent with ng-init?

I need to define a local model using ng-init. Unfortunately, I've got an error on the accent. Any idea?
Stéphane de Luca
  • 12,745
  • 9
  • 57
  • 95
1
vote
1 answer

ng-init in ng-repeat shows only the last item info

I want to loop through items like this:
Algeron
  • 269
  • 1
  • 5
  • 16
1
vote
2 answers

How to render as an error in AngularJS?

I have a select with options. I would like to initialize the select value regarding to the user logged ng-init="own = credentials.user_id". It works when the user_id is equals to the value in the select. But when it's not equals, the value selected…
Steffi
  • 6,835
  • 25
  • 78
  • 123
1
vote
1 answer

Default selected value not working using ng-init

Simply trying to make a default selected value in Angular but thus far I am having no luck. HTML Before Compile:
1 2 3
8 9