AngularJS directive 动态 template

app.directive('testwindow', function() {
return {
    restrict : 'E',
    template: '<ng-include src="getTemplateUrl()"/>', 
    replace: true,
    controller:function($scope, $element ,$http){

        $scope.getTemplateUrl=function(){
            var url= getWebRoot() + "/views/"+             
            $scope.dataStore.elementType +".html";
            return url;
    };
}        

是个比较好的解决方案,mark

posted @ 2017-07-25 09:59  Alan大bug  阅读(1361)  评论(0编辑  收藏  举报