1
1
'use strict' ;
2
2
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 ) {
5
5
var html = '<title ng-if="head.title">{{head.title}}</title>' +
6
6
'<meta name="keywords" content="{{head.keywords}}" ng-if="head.keywords">' +
7
7
'<meta name="description" content="{{head.description}}" ng-if="head.description">' +
@@ -15,7 +15,9 @@ angular.module('w11k.angular-seo-header').directive('head', ['$rootScope', '$com
15
15
elem . append ( $compile ( html ) ( scope ) ) ;
16
16
scope . head = { } ;
17
17
18
- $rootScope . $on ( '$stateChangeStart' , function ( event , toState , toParams ) {
18
+ $transitions . onStart ( { } , function ( trans ) {
19
+ let toState = trans . to ( )
20
+ let toParams = trans . params ( )
19
21
if ( toState . data && toState . data . head ) {
20
22
// head data are available for upcoming view, directive jumps in:
21
23
@@ -71,4 +73,4 @@ angular.module('w11k.angular-seo-header').directive('head', ['$rootScope', '$com
71
73
} ) ;
72
74
} } ;
73
75
}
74
- ] ) ;
76
+ ] ) ;
0 commit comments