在我的HTML中使用rootScope变量 [英] Use rootScope variables in my html
本文介绍了在我的HTML中使用rootScope变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我们可以像这样在我们的角度html中轻松使用范围变量:
So we can use scope variables in our angular html easily like this:
<!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
:
Is using yourName
from the scope I was hoping to do:
<h1>Hello {{yourName}} you are in in {{$rootScope.zoneName}}!</h1>
是否可以这样引入$rootScope
变量?
Is it possible to bring $rootScope
variables in like this?
推荐答案
您无需在html中指定$rootScope
.您可以像使用$scope
变量
You do not need to specify $rootScope
in html. You can use it the same way as you use $scope
variables
只需更新
<h1>Hello {{yourName}} you are in in {{$rootScope.zoneName}}!</h1>
到
<h1>Hello {{yourName}} you are in in {{zoneName}}!</h1>
这篇关于在我的HTML中使用rootScope变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文