Skip to content

Commit e856ec3

Browse files
authored
update for ui-router 1.0
Hi, $rootScope.$on('$stateChangeStart') is depracated in ui-rotuer 1.0\ angular-ui/ui-router#2720
1 parent 78f0075 commit e856ec3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

angular-seo-header.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
angular.module('w11k.angular-seo-header', []);
3-
angular.module('w11k.angular-seo-header').directive('head', ['$rootScope', '$compile',
4-
function($rootScope, $compile) {
3+
angular.module('w11k.angular-seo-header').directive('head', ['$rootScope', '$compile', '$transitions',
4+
function($rootScope, $compile, $transitions) {
55
var html ='<title ng-if="head.title">{{head.title}}</title>' +
66
'<meta name="keywords" content="{{head.keywords}}" ng-if="head.keywords">' +
77
'<meta name="description" content="{{head.description}}" ng-if="head.description">' +
@@ -15,7 +15,9 @@ angular.module('w11k.angular-seo-header').directive('head', ['$rootScope', '$com
1515
elem.append($compile(html)(scope));
1616
scope.head = {};
1717

18-
$rootScope.$on('$stateChangeStart', function (event, toState,toParams) {
18+
$transitions.onStart( {} , function (trans) {
19+
let toState = trans.to()
20+
let toParams = trans.params()
1921
if(toState.data && toState.data.head){
2022
// head data are available for upcoming view, directive jumps in:
2123

@@ -71,4 +73,4 @@ angular.module('w11k.angular-seo-header').directive('head', ['$rootScope', '$com
7173
});
7274
}};
7375
}
74-
]);
76+
]);

0 commit comments

Comments
 (0)