Replace ng-include node with template?

前端 未结 7 990
感情败类
感情败类 2020-11-30 23:36

Kinda new to angular. Is it possible to replace the ng-include node with the contents of the included template? For example, with:

7条回答
  •  死守一世寂寞
    2020-11-30 23:58

    So thanks to @user1737909, I've realized that ng-include is not the way to go. Directives are the better approach and more explicit.

    var App = angular.module('app', []);
    
    App.directive('blah', function() {
        return {
            replace: true,
            restrict: 'E',  
            templateUrl: "test.html"
        };
    });
    

    In html:

    
    

提交回复
热议问题