angular.js - Dynamically change submodule ng-controller
ringa_lee
ringa_lee 2017-05-15 16:58:36
0
3
539

Controller that wants to dynamically control the loading of submodules

ng-controller="{{myCtrl}}"

But this will cause an error and the system will prompt that myCtrl is not a function.

It should be a rendering priority problem, that is, the ng-controller renders too fast, and the subsequent variable values ​​​​have not yet been obtained.

Please give me some advice, what should I do about this?

ringa_lee
ringa_lee

ringa_lee

reply all(3)
Ty80

Why do we need to add double brackets? If myCtrl是个正确controller, just remove the double brackets and write directly.

巴扎黑

Obviously angular parses the parameters of the ngController directive as strings, not expressions!

Ty80

ng-controller="myCtrl" is fine. . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template