AngularJS版本问题? [英] AngularJS version issue?
本文介绍了AngularJS版本问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是一个学习者,和遗憾,如果不是要问一个简单的问题,正确的地方,请告诉我到合适的论坛。
<!DOCTYPE HTML>
< HTML和GT;
<头LANG =ENGT&;
<间的charset =UTF-8>
<标题>角举例:2'; /标题> <脚本类型=文/ JavaScript的SRC =https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js>< / SCRIPT>
<脚本类型=文/ JavaScript的
SRC =FirstCtrl.js> < / SCRIPT>< /头><身体GT;
<! - 控制器 - >< DIV NG-应用=>
< DIV NG控制器=FirstCtrl>
< H1> {{data.message +世界}}< / H1>
< DIV CLASS ={{data.message}}>
将我包裹在一个基础组成部分
< / DIV>
< / DIV>
< / DIV>< /身体GT;
< / HTML>
FirstCtrl.js
函数FirstCtrl($范围){ $ scope.data = {消息:你好};
}
如果我用下面的版本它的作品。
<$p$p><$c$c>src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.2.3/angular.min.js\"></script>我如何决定使用哪一个?什么是这里的问题
解决方案
在评论 tasseKATT
规定什么是正确的事情。
为了解决这个采用了棱角分明1.3+必须先定义你的模块,无论是在标记和code:
&LT; DIV NG-应用=对myApp&GT;
angular.module('对myApp',[]);
那么你的控制器添加到该模块:
//控制器\\名称/
angular.module('对myApp')控制器('FirstCtrl',FirstCtrl)。
//函数定义控制器/ \\
I am a learner, and sorry if it is not the right place to ask a trivial question, please direct me to the suitable forum.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title> Angular Example: 2</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js"></script>
<script type="text/javascript"
src="FirstCtrl.js"> </script>
</head>
<body>
<!-- Controllers-->
<div ng-app="">
<div ng-controller="FirstCtrl">
<h1>{{data.message + " world"}}</h1>
<div class="{{data.message}}">
Wrap me in a foundation component
</div>
</div>
</div>
</body>
</html>
FirstCtrl.js
function FirstCtrl($scope){
$scope.data = {message: "Hello"};
}
If I use the following version it works.
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.3/angular.min.js"></script>
How can I decide which one to use? What is the issue here
解决方案
In the comments tasseKATT
specified exactly what is going on correctly.
In order to resolve this using angular 1.3+ you must define your module, both in markup and in code:
<div ng-app="myApp">
angular.module('myApp', []);
Then add your controller to that module:
//name of the controller \/
angular.module('myApp').controller('FirstCtrl', FirstCtrl);
//function that defines your controller /\
这篇关于AngularJS版本问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文