• Blogs (9)
    • 📱 236 - 992 - 3846

      📧 jxjwilliam@gmail.com

    • Version: ‍🚀 1.1.0
  • 2 ways to replace ui.bootstrap default template

    Blogs20152015-08-14


    2 ways to replace ui.bootstrap default template

    The following are 2 ways to replace ui.bootstrap default template which refer to stackoverflow.com:

    1. use Decoreate:
    angular.module('jsbin', ['ui.bootstrap']).config(Decorate);
    
    Decorate.inject = ['$provide'];
    
    function Decorate($provide) {
    
        $provide.decorator('alertDirective', function ($delegate) {
    
            var directive = $delegate[0];
            directive.templateUrl = "alertOverride.tpl.html";
            return $delegate;
        });
    }
    
    //2. use run and $templateCache:
    angular.module("template/alert/alert.html", []).run(["$templateCache",
     function ($templateCache) {
    
      $templateCache.put("template/alert/alert.html",
       "<div class='alert' ng-class='type && "alert-" + type'>n" +
       " <button ng-show='closeable' type='button' class='close' ng-click='close()'>Close</button>n" +
       "  <div ng-transclude></div>n" +
       "</div>");
    }]);