我正在尝试将route
属性绑定到 src ng-include
:
配置.js
$routeProvider.when('/services', {
templatePATH: '/views/services.html'
});
索引.html
<html lang="en" ng-app="myApp" ng-controller="AppController">
<body>
<div ng-include src="{{page}}" class="container"></div>
</body>
</html>
控制器.js
controller('AppController', ['$scope','$route','$routeParams', function($scope, $route, $routeParams) {
var render = function(){
$scope.page = $route.current.templatePATH;
};
$scope.$on("$routeChangeSuccess",function( $currentRoute, $previousRoute ){
render();
});
}]).
这就是我想到的地方。奇怪的是,指令注入的templateURL
页面加载时的 DOM 中看到然而可悲的是,这行不通。src
ng-include
有可能实现这种约定吗?