Skip to content

Commit

Permalink
Merge pull request #7 from fduch2k/template-cache
Browse files Browse the repository at this point in the history
Template moved into template cache, to allow change it
  • Loading branch information
matowens committed Mar 12, 2015
2 parents 8767faa + eb4367d commit e75da04
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/scripts/ng-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@
*/
var module = angular.module('ngNotify', []);

module.run(['$templateCache', function($templateCache) {
$templateCache.put('templates/ng-notify/ngNotify.html',
'<div class="ngn" ng-class="ngNotify.notifyClass">' +
'<span class="ngn-dismiss" ng-click="dismiss()">&times;</span>' +
'<span ng-bind="ngNotify.notifyMessage"></span>' +
'</div>'
);
}]);

module.provider('ngNotify', function() {

this.$get = ['$document', '$compile', '$rootScope', '$timeout', '$interval',
this.$get = ['$document', '$compile', '$rootScope', '$timeout', '$interval', '$templateCache',

function($document, $compile, $rootScope, $timeout, $interval) {
function($document, $compile, $rootScope, $timeout, $interval, $templateCache) {

// Defaults...

Expand Down Expand Up @@ -61,12 +70,7 @@
// Template and scope...

var notifyScope = $rootScope.$new();
var tpl = $compile(
'<div class="ngn" ng-class="ngNotify.notifyClass">' +
'<span class="ngn-dismiss" ng-click="dismiss()">&times;</span>' +
'<span ng-bind="ngNotify.notifyMessage"></span>' +
'</div>'
)(notifyScope);
var tpl = $compile($templateCache.get('templates/ng-notify/ngNotify.html'))(notifyScope);

$document.find('body').append(tpl);

Expand Down

0 comments on commit e75da04

Please sign in to comment.