Questions tagged [ng-init]

ngInit is an AngularJS directive that 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.

103 questions
95
votes
2 answers

AngularJS: How to set a variable inside of a template?

How can I avoid having the {{f = ...}} statement in the third line print out the content of forecast[day.iso]? I want to avoid using forecast[day.iso].temperature and so on for every iteration.
{{$index}} -…
Daniel F
  • 13,684
  • 11
  • 87
  • 116
21
votes
2 answers

How am I supposed to pass data from serverside controller an AngularJS controller?

I've encountered what I believe to be a common scenario, in which I am using an MVC pattern (specifically ASP.NET's MVC framework) for a web application, with AngularJS on the front-end. My problem is that I have a particular value which is part of…
3
votes
1 answer

ng-options with array of objects linking to an ng-init

I am creating a select with ng-options that loops through an array of objects linking to an ng-init. However, the problem is, it has to pass the correct variable through ng-change as well. Right now the code below will make ng-init work and pick the…
lettman1
  • 95
  • 6
3
votes
2 answers

AngularJS ng-init is not working in ng-repeat

I need a Sum of Balance from the Following Data in HTML not in JS Controller Function. So, I used the ng-init within the ng-repeat. But I can't able to get the result. My JSON Data is { "records":[ { "ldat":"2014-08-13", …
3
votes
2 answers

AngularJS - Accessing ng-init variables from run method

1) I have variables initialized in ng-init Eg - ng-init="password='Mightybear'"; 2) I want to access it from the .run method. Eg - anguar.module("ngApp", []) .run(function() { //Access password here }); Below scenarios I have tried, and did…
2
votes
2 answers

Equivalent of ng-init in reactjs

I am converting my project from angular to reactjs. But I got stuck at ng-init. I don't know what is the equivalent of ng-init in reactjs in react way. Please help me, anyone, with this.
Djkrishna
  • 23
  • 1
  • 3
2
votes
1 answer

Can we delay rendering in angularjs until all variables get required values from callbacks

Update 1- IsShopToShowTerminated returns true which is expected but values doesn't reflects in the view. I have shared angularjs code. There IsShopToShowTerminated is always undefined and doesn't depict the required value. I think problem is…
Charlie
  • 4,827
  • 2
  • 31
  • 55
2
votes
1 answer

Add multi dimension object in ng-init in angular js

I want to add multi dimension object in ng-init like object({ friends:[ {name:John,phone:555-1276}, {name:Mary,phone:800-BIG-MARY}, {name:Mike,phone:555-4321}, {name:Adam,phone:555-5678}, …
Afaq Arif
  • 23
  • 3
2
votes
3 answers

Using ng-init to bind a variable to a value in my controller

I'm working on an editor page. I receive a Json from my server, that contains: { "Q_id": 1, "isMultipuleAns": 0, "Q_mediaType": "page" } And I'm trying to put the information in input div (type=text) or textarea div.