execute function automatically in Angularjs -


I have to execute this function automatically, but I'm not working.

  $ scope.checkdate = function () {$ scope.checked = 0; $ Scope.unchecked = 0; (Var i = 0; i & lt; $ scope.inventories.length; i ++) {If ($ scope.inventories [i] .modified === $ scope.time) {$ scope.checked = $ scope. Checked + 1; } And if ($ scope.time2! == $ scope.time) {$ scope.unchecked = $ scope.unchecked + 1; }}}; $ Scope.checkdate ();   

And my template looks like this:

  & lt; Ul ng-init = "checkdate ()" & gt; & Lt; Li & gt; & Lt; Input type = "checkbox" /> Checked {{Check}} & lt; / li & gt; & Lt; Li & gt; & Lt; Input type = "checkbox" /> Unchecked {{uncheck}} & lt; / li & gt; & Lt; Li & gt; & Lt; Input type = "checkbox" /> All & lt; / li & gt; & Lt; / Ul & gt;  

First of all, almost ng-init to: < / P>

The only proper use of NGIITIT is to aliasing the special properties of NGEREPET

So you should not use it in your example.

First of all, your init function should not be connected to the $ scope , because it is not required that it should be a private function of the controller.

Third, we can not see the definition of your controller. It can be very well that you have not made one and thus - the Konal will not care about the rest of the codes.

Fifth, you will get a response at any time, with an example created a JS Friedal :)

However, your code should show something like this (boilerplate). You should help.

HTML Template:

  & lt; Ul ng-controller = "MyController" & gt; & Lt; Li & gt; & Lt; Input type = "checkbox" /> Checked {{Check}} & lt; / li & gt; & Lt; Li & gt; & Lt; Input type = "checkbox" /> Unchecked {{uncheck}} & lt; / li & gt; & Lt; Li & gt; & Lt; Input type = "checkbox" /> All & lt; / li & gt; & Lt; / Ul & gt;   

MyController.js :

  function MyController () {$ scope.checked = 0; $ Scope.unchecked = 0; // Define what should be done during the initialization function init () {// I have not checked your code, but there are some unrecognized variables in this for $ scope.inventories .... (var i = 0; i & lt; $ scope.inventories.length; i ++) {If ($ scope.inventories [i] .modified === $ scope.time) {$ scope.checked = $ scope.checked + 1 ; } And if ($ scope.time2! == $ scope.time) {$ scope.unchecked = $ scope.unchecked + 1; } } } in this(); // Call your private Init function here }    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -