2015-10-14 57 views
0

我使用的角度,引導日曆資料庫,文檔可以讓我加我的自定義模板,只是增加使用裝飾正確的方法angularjs

app.config(function($provide) { 
    $provide.decorator('mwlCalendarDayDirective', function($delegate) { 
    var directive = $delegate[0]; 
    delete directive.template; //the calendar uses template instead of template-url so you need to delete this 
    directive.templateUrl = 'path/to/my/slide/box/template.html'; 
    return $delegate; 
    }); 
}); 

這是我很好,但我的問題是,以取代與另一個模板,它保留了相同的控制器?

回答

1

是的,裝飾這樣的指令是完全正確的,它們只是包含(按其註冊順序)的Directive後綴的服務。這種方法修改了指定的屬性,同時保持DDO的其餘部分不變。

對於其他DDO屬性,除compile /(post)link/pre(鏈接)之外,該過程是直接的,這對於修補有點棘手。