AngularJS error: 'argument 'FirstCtrl' is not a function, got undefined'

前端 未结 16 1198
时光取名叫无心
时光取名叫无心 2020-12-01 05:55

I noticed the same question was asked a few times here, I tried so solve it but nothing helps.

I\'m following this tutorial with the egghead videos.

But whe

16条回答
  •  抹茶落季
    2020-12-01 06:37

    You have 2 unnamed ng-app directives in your html.
    Lose the one in your div.

    Update
    Let's try a different approach.
    Define a module in your js file and assign the ng-appdirective to it. After that, define the controller like an ng component, not as a simple function:

    and the js part:

    angular.module('myAppName', [])
        .controller('FirstCtrl', function($scope) {
             $scope.data = {message: 'Hello'};
        });
    

    Here's an online demo that is doing just that : http://jsfiddle.net/FssbL/1/

提交回复
热议问题