angular.js - 使用angularjs,为什么报controller没定义?
迷茫
迷茫 2017-05-15 16:50:40
0
2
610

刚开始学angular啊,试着写的小demo,就报错了。。。

html:

js:

报错:

------新的报错信息= =#----

按@张伯函 的办法改写了一下

还是报同样的错误

然后我把ng-app="myApp"

报了一个新的错误T^T

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
小葫芦

Cannot be used directlyfunction来定义controller

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

myApp.controller('GreetingController', ['$scope', function($scope) {
  $scope.greeting = 'Hola!';
}]);

Reference: https://docs.angularjs.org/guide/controller


Holdng-app改成ng-app="myApp"ah, dear

PHPzhong

How did the original poster solve the problem? Urgent, waiting online

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