<body> <div ng-app="myApp"> <div ng-controller="firstController"> <div ng-bind="text"></div> <div ng-include="url"></div> <div ng-include="tpl"></div> </div> <script type="text/ng-template" id="tpl.html"> Content of the template </script> </div> <script type="text/javascript"> var app = angular.module("myApp", []); app.controller(‘firstController‘, [‘$scope‘, function ($scope) { $scope.text = "Demo"; // ng-include 用法 $scope.url = "/Demo/Other"; $scope.tpl = "tpl.html"; }]); </script> </body>
时间: 2024-10-03 14:52:00