问题描述
我在angularjs新。我已经创建了一个HelloWorld程序。对角参考我使用CDN。但问题是程序正在版本1.0.8版本,但在1.3.14版本不工作。我不能说是什么问题。我的code为波纹管式给出:
I am new in angularjs. i have created a helloworld program. for angular reference i used CDN. but the problem is the program is working on version 1.0.8 version but not working in 1.3.14 version. I can not say what is the problem. My code is given bellow:
<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="utf-8"/>
</head>
<body>
<header>
<h1 ng-controller="HelloWorldCtrl">{{helloMessage}}</h1>
</header>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<!--<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>-->
<script type="text/javascript">
function HelloWorldCtrl($scope) {
$scope.helloMessage = "Hello World from Nasir Uddin";
}
</script>
</body>
</html>
同样的事情发生,如果我下载的角版本1.0.8,并把它放在那么我的项目文件夹它的工作,但如果我下载1.3.14,并把它放在我的项目文件夹,然后它不工作。请帮我找到解决方案。
Same thing happens if I download the angular 1.0.8 version and put it in my project folder then it's working but if i download the 1.3.14 and put it my project folder then it's not working. Please help me to find the solution.
推荐答案
那么你可以以这种方式与新版本中实现这一目标。
Well you can achieve this with new version in this way.
<!DOCTYPE html>
<html ng-app="myModule">
<head>
<meta charset="utf-8"/>
</head>
<body>
<header>
<h1 ng-controller="HelloWorldCtrl">{{helloMessage}}</h1>
</header>
<!--<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>-->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script type="text/javascript">
angular.module('myModule',[]).config(['$controllerProvider', function($controllerProvider) {
$controllerProvider.allowGlobals();
}]);
function HelloWorldCtrl($scope) {
$scope.helloMessage = "Hello World from Nasir Uddin";
}
</script>
</body>
</html>
您可以阅读更多的这里
搜索结果
编辑code -
EDIT CODE-
结果
在头部使用这样
In header use like this
<h1 ng-controller="HelloWorldCtrl" ng-bind="helloMessage"></h1>
要避免HTML波动
这篇关于我的&QUOT;世界,你好&QUOT;角程序没有在1.3.14版本工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!