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
0
votes
1 answer

Controlling ng-repeat iterations

HTML :

{{data.name}}

  • {{step.name}}
0
votes
0 answers

Angular Error: $parse:ueoe Unexpected End of Expression with EJS

I'm getting unexpected End of expression error when I pass nodejs data to to ng-init. I'm confident I'm doing it right however I'm getting the error message above I call ng-init like so:
Kenny Nguyen
  • 222
  • 2
  • 13
0
votes
0 answers

AngularJs - Expression is not being valuated correctly

I have defined an expression in ng-init which is being evaluated to false but when I assign it to a variable, its being evaluated to true.
Shaam
  • 92
  • 13
0
votes
1 answer

How to delay my ng-init function until my api call is success

I am working on dynamic form with ng-repeat. I am using oi-select for loading my location. I am loading this form inside modal popup. Regarding get my location values i am calling one api function on click of my modal open button. On success of this…
0
votes
1 answer

How to call AngularJS function after partial postback in asp.net?

How to call AngularJS function after partial postback (from ascx page) in ASP.Net inside an UpdatePanel. Initially I call angular function on ng-init. But after the partial postback, the function is not called. How could I call the…
0
votes
1 answer

Increment a counter based on number of elements

I have a below snippet for showing TABS which is static HTML. But each item would get shown on UI based on some business logic. Based on the number of tabs I need to set a width. For e.g if two tabs are shown then I need to equally divide tabs i.e…
Parag Diwan
  • 3,007
  • 2
  • 19
  • 37
0
votes
0 answers

Call a jQuery function in element ng-init to access element with id, element is formed in ng-repeat

I need to access element (dom) with id in a jQuery function, element is inside ng-repeat of Angular (generating dynamic id for each element), and we are calling a jQuery function in element ng-bind or ng-init. Code:
0
votes
2 answers

angularjs set default value ng-model using value from another ng-model

I would like to pass the value of an ng-model that the user sets in a another form field select options to another ng-model as initial value in the same form. In this example, I want the ng-init value of myModel.fieldB to be the value…
passion
  • 1,000
  • 6
  • 20
  • 47
0
votes
2 answers

initialize a scope variable with angularJs

I'm always using ng-init="controllerFunction()" to get data from the server and display it on a table, chart or anything else and it needs to get called on every page loading. Now using ng-init is doing the job but is it the best practice ?
OddDev
  • 1,521
  • 7
  • 23
  • 45
0
votes
1 answer

Difference between ng-init and onload for function invoke [Angular JS]

I am working on a angular application and have a scenario where i want to focus on a text field on page load. i have tried HTML5 autofocus but have to find an alternative solution for this since there is a browser compatibility issue for the same. I…
Sha
  • 1,826
  • 5
  • 29
  • 53
0
votes
2 answers

ng-init function called 1000+ times

I have a module like this : angular.module('BlurAdmin.pages.calendar', []) .config(routeConfig); /** @ngInject */ function routeConfig($stateProvider, $urlRouterProvider) { $stateProvider .state('calendar', { url:…
OddDev
  • 1,521
  • 7
  • 23
  • 45
0
votes
2 answers

Passing value in function properly in AngularJS

I have the following function which takes variable description as parameter $scope.relsingle = function(description) { console.log(description); var url = $scope.url+'/api/descrelation?limit=4&description='+description; …
0
votes
2 answers

array variable in a div tag replicates in all the other div tags in angularJS

The array ar array in first #div1 is repeated in all the div. All other div have the common array variable name ar. I tried with different names.
0
votes
1 answer

Assigning value to ng-init from Ajax result

I've a form with one input field to submit the student id via AJAX and I'm fetching some JSON result from the AJAX request. Now the returned data from AJAX request need to be assigned to ng-init in the input field (phone) below the form. Please help…
Naresh
  • 862
  • 3
  • 12
  • 35
0
votes
1 answer

Angular variable initialized using ng-init is always undefined

I am learning AngularJS. Now I am initializing variable using ng-init. But the variable value is always undefined. My code is below: Angularjs popup
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
1 2 3
8 9