search

Home  >  Q&A  >  body text

angular.js - Dynamically change submodule ng-controller

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_leeringa_lee2821 days ago541

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-05-15 17:00:36

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

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-15 17:00:36

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

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 17:00:36

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

    reply
    0
  • Cancelreply