javascript - AngularJS pass variable through to a template -
i want pass variable or text through template shows value inside template.
i come across jsfiddle shows working uses ng-repeat
. there simplere way without using 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 {{ 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 {{ name }}</div> </script>
js:
var myapp = angular.module('myapp',[]); myapp.controller('ctrl', function($scope) { $scope.name = "john"; });
you set variable in scope, , include template?
Comments
Post a Comment