问题描述
我刚从开始学习AngularJS。我正在尝试练习示例,他们在教程中提到过。每件事情都很好,但是当我来到AngularJS控制器时,它不能正常工作,因为在。我将我的代码分成了这个。
我的脚本如下所示:
function personController($ scope){
$ scope.firstName = 约翰;
$ scope.lastName =Doe;
}
尽量帮助我,并为我提供一个很好的教程(或免费的pdf文件)。
这是您的 。
角度控制器定义必须看起来很好像这样:
$ b $ pre $ angular.module(app,[]).controller(personController,function($ scope) {
$ scope.firstName =John;
$ scope.lastName =Doe;
});
毫无疑问,是学习基础知识的最佳教程 Angular是 one!
希望这会有所帮助。
I just now started learning on AngularJS from w3schools. I am trying to practice examples what ever they have mentioned in the tutorials. Every thing works fine but when i came to "AngularJS Controllers" it is not working properly as working well in w3schools Try it Yourself ». I ve forked my code into this fiddle example.My script looks like this:
function personController($scope) {
$scope.firstName= "John";
$scope.lastName= "Doe";
}
Try to help me out and suggest me a good tutorial(or any free pdf file).
This is your corrected fiddle.
It is a good practice for angular that the controller definition must look something like this:
angular.module("app", []).controller("personController", function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
And, without doubt, the best tutorial ever for learning the basics of Angular is the CodeSchool one!
Hope this helps.
这篇关于AngularJS ng控制器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!