test(angular_1_router): apply annotations to controller constructors
Until Angular 1.5.1 is released, the `$routeConfig` and `$routerCanActivate` annotations for components must live on the controller constructor. In Angular 1.5.1, it will automatically copy these annotations across from the component definition file. Closes #7319
This commit is contained in:
parent
83f0e7c975
commit
7f22bd62ab
2
modules/angular1_router/src/ng_route_shim.js
vendored
2
modules/angular1_router/src/ng_route_shim.js
vendored
@ -150,7 +150,7 @@
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
// we resolve the locals in a canActivate block
|
// we resolve the locals in a canActivate block
|
||||||
componentDefinition.$canActivate = function() {
|
componentDefinition.controller.$canActivate = function() {
|
||||||
var locals = angular.extend({}, routeCopy.resolve);
|
var locals = angular.extend({}, routeCopy.resolve);
|
||||||
|
|
||||||
angular.forEach(locals, function(value, key) {
|
angular.forEach(locals, function(value, key) {
|
||||||
|
@ -466,10 +466,10 @@ describe('Navigation lifecycle', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options.$canActivate) {
|
if (options.$canActivate) {
|
||||||
factory.$canActivate = options.$canActivate;
|
controller.$canActivate = options.$canActivate;
|
||||||
}
|
}
|
||||||
if (options.$routeConfig) {
|
if (options.$routeConfig) {
|
||||||
factory.$routeConfig = options.$routeConfig;
|
controller.$routeConfig = options.$routeConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
$compileProvider.directive(name, factory);
|
$compileProvider.directive(name, factory);
|
||||||
|
@ -306,14 +306,15 @@ describe('navigation', function () {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
function registerDirective(name, options) {
|
function registerDirective(name, options) {
|
||||||
|
var controller = getController(options);
|
||||||
function factory() {
|
function factory() {
|
||||||
return {
|
return {
|
||||||
template: options.template || '',
|
template: options.template || '',
|
||||||
controllerAs: name,
|
controllerAs: name,
|
||||||
controller: getController(options)
|
controller: controller
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
applyStaticProperties(factory, options);
|
applyStaticProperties(controller, options);
|
||||||
$compileProvider.directive(name, factory);
|
$compileProvider.directive(name, factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +324,7 @@ describe('navigation', function () {
|
|||||||
template: options.template || '',
|
template: options.template || '',
|
||||||
controller: getController(options),
|
controller: getController(options),
|
||||||
}
|
}
|
||||||
applyStaticProperties(definition, options);
|
applyStaticProperties(definition.controller, options);
|
||||||
$compileProvider.component(name, definition);
|
$compileProvider.component(name, definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ describe('router', function () {
|
|||||||
if (options.template) definition.template = options.template;
|
if (options.template) definition.template = options.template;
|
||||||
if (options.templateUrl) definition.templateUrl = options.templateUrl;
|
if (options.templateUrl) definition.templateUrl = options.templateUrl;
|
||||||
|
|
||||||
applyStaticProperties(definition, options);
|
applyStaticProperties(definition.controller, options);
|
||||||
angular.module('testMod').component(name, definition);
|
angular.module('testMod').component(name, definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user