Manually bootstrapping AngularJS and then getting the module

后端 未结 4 976
闹比i
闹比i 2021-02-14 00:18

Generally, I\'d do the following and there would be an ng-app in my HTML:

var myApp = angular.module(\"myApp\", []);

myApp.controller(\"AttributeCt         


        
4条回答
  •  遇见更好的自我
    2021-02-14 01:03

    Not sure if this counts as a bug or an implementation decision (albeit a seemingly poor one). Adding an empty array solves the undefined require problem that you were having and should solve your problem overall.

    var app = angular.module("myApp", []); // create a module
    
    app.controller("AttributeCtrl", function($scope) {
       $scope.master = { name: "some name"};
    });`
    

    Also, in your fiddle you call {{name}} which won't render. You should be calling {{master.name}}


    Edit

    Thank you all for the downvotes .. Here's a working example. Good luck!

    http://plnkr.co/edit/UowJpWYc1UDryLLlC3Be?p=preview

提交回复
热议问题