[英]I want to print a static variable inside my html using angualrjs
id是我的html中一个名为Benny的静态变量。 我想在屏幕上打印id,但是空白。
<scheduled-event
id1 = "Benny"
event="event"
ng-repeat="event in $ctrl.adherence.events">
<h2>{{id1}}</h2>
</scheduled-event>
要将静态变量放在作用域上,请使用ng-init
指令:
<script src="//unpkg.com/angular/angular.js"></script> <body ng-app> <scheduled-event ng-init="id1='Benny'" event="event" ng-repeat="event in [1,2]"> <h2>{{id1}}</h2> </scheduled-event> </body>
有关更多信息,请参见《 AngularJS ng-init
指令API参考》 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.