Questions tagged [angularjs-ng-init]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
45 views

Calling async method in ngInit not working in Angular 14 [duplicate]

I have a problem with calling an “async” method in “ngInit” method in angular 14 here is the method I want to call when component initialized: async setInterfaceDatatableHeaders() { var bankName = ...
0 votes
1 answer
456 views

ng-click and ng-init variable definition

I am trying to make table header sorter work by using ng-click and ng-init. Examples in angular js documents require modules, and if I install and update that module, my SPA falls apart for some ...
0 votes
1 answer
204 views

How can assign value to ng-init with conditional expression?

I want to assign variable in ng-init with conditional expression but it's not working with my code. I need to assign isCollapsed value true false with conditional expression. <a class="email" ng-...
0 votes
1 answer
232 views

Nested ng-repeats with bootstrap collapse, trouble with $index and ng-init

I have a bootstrap collapse accordion with multiple ng-repeats: <div class="subdiv-wrapper"> <div class="panel-group" id="accordion1" ng-repeat="admin in subdivisions" ng-init="...
  • 41
1 vote
4 answers
106 views

Angularjs - nested ng-repeat global index

I have next template: <div data-ng-repeat="supplier in order.Suppliers" data-ng-init="supplierIndex = $index"> <div data-ng-repeat="group in supplier.Groups"> {{something}} ...
  • 6,483
0 votes
0 answers
57 views

Am I abusing ng-init?

I have two ng-repeats, one nested inside another, and I have a function I want to run after the last item has rendered. Current I have it working as follows: <tr ng-repeat="requestResult in vm.$...
  • 1,084
2 votes
2 answers
335 views

AngularJS revert selected value of control nested in ng-repeat on dialog cancel

I want to revert a select tag value that is inside a ng-repeat after cancelling a confirm dialog. Here is what I have so far: Relevant HTML: <table> <tbody> <tr ng-repeat="...
0 votes
0 answers
67 views

Passing value from one component to the other in html using angular js ng-init

I tried doing the above thing using ng-init but I guess the scope of ng-init did not allow me to do so. Lets suppose, I have a dropdown getting populated with a ng-repeat from an array having values ...
user avatar
0 votes
2 answers
46 views

Does ng-init and ng-repeat bind properly?

<tr data-ng-repeat="x in AList" data-ng-init="loopIndex=$index;"> <select data-ng-model='y.value' style="width:80%;margin-left:20px;" data-ng-change="filter()" data-ng-init="test123=x.name;"&...
user avatar
0 votes
1 answer
143 views

Controlling ng-repeat iterations

HTML : <div ng-repeat="data in $ctrl.list"> <div ng-init="$ctrl.applyAction(data)"> <h4>{{data.name}}</h4> <ul ng-if="data.steps"> <...
0 votes
0 answers
387 views

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: <body id=...
0 votes
0 answers
37 views

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. <div class="small-6 medium-6 large-6 cell" ng-init="...
  • 92
1 vote
2 answers
417 views

Using ng-init to send data from a ng-repeat to another controller

I have a html file that runs a ng-repeat and then each item in that ng-repeat will generate a template which also has it's own controller On the html file I have something like: <div ng-repeat="...
  • 492
0 votes
1 answer
778 views

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 ...
2 votes
3 answers
539 views

ng-model overwritten within ng-repeat

I have a table with an input field, I'm setting values to ng-model in each iteration of ng-repeat. I'm getting correct values in each iteration, but all of the ng-model values are overwritten by the ...
1 vote
1 answer
1k views

how to add days to date variable on every ng-repeat loop in angularjs

I have set date variable in "ng-init" directive and i want to add days to this date variable on every ng-repeat loop like below: <table> <tr ng-repeat="n in myArr" ng-init="myDate=('...
0 votes
1 answer
654 views

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

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 ...
  • 2,887
1 vote
1 answer
418 views

Which element does myVar bind to? Problems with `ng-init` [duplicate]

I'm wondering what's happening behind the scenes when using ng-init. Sometimes ng-init does some unexpected things, and I have a hard time debugging. Let's say I have the following structure: <!-...
-1 votes
1 answer
417 views

send ng-init variable with $http.post , angularJs

How can I initialize a $scope variable using PHP so that it can be sent to the server later in an $http.post request? I tried with ng-init but it doesn't seem to work: <body ng-app="app" ng-...
0 votes
0 answers
497 views

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 ...
  • 133
0 votes
2 answers
2k views

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 ...
  • 990
-2 votes
2 answers
660 views

angularjs override ng-init value by placeholder value

I have the following input: <input type="text" placeholder="Enter your response" class="form-control" name="response" ng-model="test.response" ng-init="test.response='No Response'"/> it is ...
  • 1,105
0 votes
2 answers
2k views

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

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 ...
  • 1,796
0 votes
2 answers
622 views

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 ...
1 vote
1 answer
1k views

ng-init in Select is not working in angularJS

I have a Select element like this <select class="form-control" id="designation" ng-model="employee.designation" ng-init="select Designation = options[0]" ng-options="d for d in designations" ...
1 vote
0 answers
45 views

how to set default value after ng-options completed?

assume that this is my controller: function MainController(BaseInformation, baseInformationConstants) { var vm = this; getGenders(); function getGenders() { vm.genders = ...
0 votes
2 answers
38 views

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=...
0 votes
2 answers
33 views

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. <body ng-app=""> <div id="div1" ng-...
0 votes
1 answer
420 views

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 ...
  • 862
0 votes
1 answer
2k views

Angular variable initialized using ng-init is always undefined [duplicate]

I am learning AngularJS. Now I am initializing variable using ng-init. But the variable value is always undefined. My code is below: <!DOCTYPE html> <html lang="en"> <head> <...
  • 13.2k
1 vote
1 answer
68 views

I am using MVC 4 and angularjs in this actually I want to call an angular js function on page load

i want to invoke angularjs function (DeptSpecific) on page load and am passing ID as the parameter which is hard coded. And that i am passing via ng-init="DeptSpecific('1')". I am learning angularjs ...
1 vote
0 answers
69 views

How can I set the first accordion item in the ngRepeat to be open while the rest are not?

I'm creating a list of tables with collapsible tbodys. This code works fine but I want to have the first tbody open on default. I've tried ng-init="showReports0" on the table tag, but this doesn't ...
0 votes
1 answer
512 views

Context dictionary from Django template to Angular

I am building a web app and I want to know what is the best and the safest way to pass a variable from a django context dictionary to Angular. I have access to a variable of the context dictionary ...
1 vote
1 answer
1k views

how to set $Index to 1 every ng-repeat call

<table class="table table-bordered"> <tr ng-repeat="x in AppliedJob"> <td>{{x.JobName}}</td> <td> <span class="dropdown" ng-repeat="y in AppliedCenter| ...
user avatar
3 votes
2 answers
386 views

Assign ng-model an object in a select

I'm iterating over a range and populating new select options for each index. The options are not related to the range I am iterating over but are options of different types. Code as follows: <div ...
  • 1,307
0 votes
1 answer
223 views

How do I stop the select from losing it's selected value after any event on the page occurs?

When the page is first loaded, the select binds to the correct value (calculated by ng-init) but as soon as any button is clicked on the page, the select loses its selected value. I'm new to angularJS....
  • 176
5 votes
1 answer
274 views

ng-repeat splice showing double

For some reason, when I splice an object into my ng-repeat array, it doubles what I splice in and hides the last object in the array. However, if I click the toggle hide and "refresh" the ng-repeat, ...
  • 8,701
0 votes
1 answer
2k views

Angular JS - declaring function inside ng-init?

I have few queries. Pls find them below - 1) A function defined inside an ng-init like given below ng-init='function a() {}' errors out. Changing the syntax to variable declaration type or ...
0 votes
1 answer
415 views

Why variable initialization is required in ng-init: AngularJS

I have started leaning AngularJS. In AngularJS if we have to initialize an element lets take an example of select: <select id="s1" ng-model="vsrc" ng-init="vsrc='a.mp4'"> <option value="...
  • 14.9k
0 votes
0 answers
170 views

ng-init doesn't work in ionic collection-repeat block

I'm using the following view: <ion-item collection-repeat="scan in scans" href="#/app/scans/{{scan.local_id}}"> <h2 class="media-heading">ID: {{(scan.id ? scan.id : '--')}}</h2> ...
  • 1,145
0 votes
1 answer
393 views

Angular -- ng-init scope variable not passing into view

I have the following in my index.html <header> <select ng-model="date.month" ng-init="currentMonth" ng-options="month for month in months"> </select> <select ng-...
  • 909
2 votes
3 answers
1k views

Expression in ng-init not working with ng-repeat

So I am trying to have many divs with background images and disable the background image when I hover over any particular div. <div id="interest" class="col-md-4 col-sm-6" ng-repeat="interest in ...
0 votes
1 answer
741 views

How to select/init first value in html select option after data loads thru Angular 2 observable?

I have an html select with options that looks like this: <select [(ngModel)]="role" (ngModelChange)="roleChanged($event)"> <option *ngFor="#role of roles" [ngValue]="role">{{role.Name}...
0 votes
1 answer
138 views

ng-init not working to inizialize data in combobox (angular)

I'm trying to initialize data in combobox, and I have tried every possible ways, but nothing: <select ng-init= "account.username = githubaccounts[0].username" data-ng-model="account" data-ng-...
0 votes
1 answer
1k views

How to use ng-init with an object?

I have a dropdown whose value is an object. The html code is as follows. <div class="form-group"> <label>Goal<span class="red-ast">*</span></label><br /> ...
0 votes
2 answers
763 views

ng-init is not setting my default category in my select within my Angular app

I have the exact same problem as mentioned here: How to have a default option in Angular.js select box However none of the answers fix my issue below, I'm trying to get the first category to show up ...
  • 35.3k
0 votes
0 answers
1k views

Loading data with ng-init

I have a problem loading data in three dropdowns in my html with ngInit angular directive. I call the method initAll() in my controller from ng-init. This function loads the list of values for three ...
-4 votes
1 answer
54 views

How can I get other http.get response inside in a ng-repeat

I have this HTML http://pastebin.com/DegTb0iH has a ng-repeat rulling in rullings within it need to do the vote count of each staff, get these values as follows: http://pastebin.com/EB4KigwS the ...