javascript - Resolve in router is not updating scope in time -


Hello there

I have issue of tampering with scope variables (With resolution in router) before angular visual content renderer I am using AngularJS 1.2.16

I have where DIV is displayed on the basis of Scope Variable.

  & lt; div ng-hide = "data.show" & gt; & Lt; / Div & gt; Text to show;   

I have a controller with scope variable $ scope.arived and seeing this variable, so when it will change, the function toggleText ( ) $ scope.data.show will be set correctly / incorrect in the clock timer.

  app.controller ('view1Controller', function ($ radius, arived) {$ Scope.arived = arived; // About this next paragraph $ Talking $ $ diameter . $ Watch ('arived', toggleText); Function toggle text (newVal, oldVal) {$ scope.data.show =! $ Scope to see base content;}});   

This problem is usually working as a quote, when I use data injection from the router trough solution method.

Let's say I have this router:

  $ routerprovider When ('/ view1' {Admin: "View 1 Controller", TemplateRail: "/templates/partial1.html", Solve: {arived: Function (DataService) {Return DataService Check ();}}});   

dataService.check () is returning the promise and I $ scope.arived in the controller view1Controller

This is also working , but it is too late $ scope.arived is filled, but presented before the Angulale View That's why the text is not visible.

When I try to wrap this setter inside the controller:

  $ scope.arived = arived; In   

$ timeout , fe. 1s delay $ timeout (function () {$ scope.arived = arived;}, 1000);

It works .. But I want there is no desired delay.

Is there an event, like sung or something else, where I can fire my setter? Or is IM doing all this wrong? :)

Thank you

I think you should start the data. Show value from the promise of the solution

  app.controller ('view1Controller', function ($ radius, arived) {$ scope.arived = arived; // Talk about the next paragraph about this $ Is $ scope Data.show = arived; $ scope. $ Watch ('arived', toggle text); Function toggle text (newwall, oldwall) {$ scope.data.show =! $ Scope.data.show;}}) ;    

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 -