I am a java developer with 0 experience in java script. I am trying to learn angular and did tweak some projects to understand bit of angular. But I am definitely making some error in the basics. I am trying to run a hello world program in angular. I have an index.html
and a controller in app.js
. I am trying to call a function and show Hello {{something}} !!
. I am unable to understand where I am going wrong. Please bear with me and clarify my mistake. here is the fiddle.
我是一名java开发人员,拥有0年的java脚本经验。我正在尝试学习角度并且确实调整了一些项目来理解角度。但我肯定在基础知识上犯了一些错误。我试图以角度运行一个hello world程序。我在app.js中有一个index.html和一个控制器。我正在尝试调用一个函数并显示Hello {{something}} !!我无法理解我哪里出错了。请忍受我并澄清我的错误。这是小提琴。
var myAppModule = angular.module('myModule', []);
var appController = function ($scope) {
$scope.greeting = returnGreeting;
};
var returnGreeting = function($scope){
return 'Hi '+$scope.name+ ' !!';
}
myAppModule.controller('appController', ['$scope',appController]);
2
You didn't initialize ng-app=""
so your app is not working, also you didn't define $scope.name
so it returns undefined
你没有初始化ng-app =“”所以你的应用程序不能正常工作,你也没有定义$ scope.name所以它返回undefined
Here is the working link: http://jsfiddle.net/QUB4f/8/
这是工作链接:http://jsfiddle.net/QUB4f/8/
Spend time learning JavaScript, without the knowledge of language using complex framework is not a good idea
花时间学习JavaScript,没有使用复杂框架的语言知识也不是一个好主意
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2014/03/26/72b8da5c686ebc2a39a1cf6489ffe1d1.html。