我想将变量或文本传递给模板,以使其显示模板中的值。
我遇到jsFiddle,它显示了它的工作原理,但使用了ng-repeat
。有没有不使用此方法的简单方法ng-repeat
?
<div ng-repeat="name in ['John']" ng-include="'partial.html'"></div>
<div ng-repeat="name in ['Jack']" ng-include="'partial.html'"></div>
<script type="text/ng-template" id="partial.html">
<div>The name is {{ name }}</div>
</script>
<div ng-controller="ctrl">
<div ng-include="'partial.html'"></div>
</div>
<script type="text/ng-template" id="partial.html">
<div>The name is {{ name }}</div>
</script>
JS:
var myApp = angular.module('myApp',[]);
myApp.controller('ctrl', function($scope) {
$scope.name = "John";
});
您只是在范围内设置变量,并包含模板?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句