【发布时间】:2015-07-29 17:57:27
【问题描述】:
所以我们可以像这样在 Angular html 中轻松使用范围变量:
<!doctype html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
</head>
<body>
<div>
<label>Name:</label>
<input type="text" ng-model="yourName" placeholder="Enter a name here">
<hr>
<h1>Hello {{yourName}}!</h1>
</div>
</body>
</html>
例如:
<h1>Hello {{yourName}}!</h1>
在我希望的范围内使用yourName:
<h1>Hello {{yourName}} you are in in {{$rootScope.zoneName}}!</h1>
这样可以带$rootScope变量吗?
【问题讨论】:
标签: angularjs