angular.js - 动态改变子模块ng-controller
ringa_lee
ringa_lee 2017-05-15 16:58:36
0
3
505

想动态的控制子模块加载的控制器

ng-controller="{{myCtrl}}"

但是这样会报错,系统提示myCtrl不是一个function。

应该是渲染的优先级问题,就是ng-controller渲染太快,后面的变量值还没来的及取到。

求大神指点下,这个要怎么办?

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