fix(angular1_router): support templateUrl components
This commit is contained in:

committed by
Pete Bacon Darwin

parent
e7470d557d
commit
d4a4d81173
@ -95,6 +95,32 @@ describe('router', function () {
|
||||
expect(elt.text()).toBe('Home (true)');
|
||||
}));
|
||||
|
||||
it('should work with a templateUrl component', inject(function($location, $httpBackend) {
|
||||
var $routerOnActivate = jasmine.createSpy('$routerOnActivate');
|
||||
$httpBackend.expectGET('homeCmp.html').respond('Home');
|
||||
registerComponent('homeCmp', {
|
||||
templateUrl: 'homeCmp.html',
|
||||
$routerOnActivate: $routerOnActivate
|
||||
});
|
||||
|
||||
registerComponent('app', {
|
||||
template: '<div ng-outlet></div>',
|
||||
$routeConfig: [
|
||||
{ path: '/', component: 'homeCmp' }
|
||||
]
|
||||
});
|
||||
|
||||
compile('<app></app>');
|
||||
|
||||
$location.path('/');
|
||||
$rootScope.$digest();
|
||||
$httpBackend.flush();
|
||||
var homeElement = elt.find('home-cmp');
|
||||
expect(homeElement.text()).toBe('Home');
|
||||
expect($routerOnActivate).toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
|
||||
function registerDirective(name, options) {
|
||||
function factory() {
|
||||
return {
|
||||
@ -111,9 +137,15 @@ describe('router', function () {
|
||||
|
||||
var definition = {
|
||||
bindings: options.bindings,
|
||||
template: options.template || '',
|
||||
controller: getController(options),
|
||||
};
|
||||
if (options.template) {
|
||||
definition.template = options.template;
|
||||
}
|
||||
if (options.templateUrl) {
|
||||
definition.templateUrl = options.templateUrl;
|
||||
}
|
||||
|
||||
applyStaticProperties(definition, options);
|
||||
$compileProvider.component(name, definition);
|
||||
}
|
||||
|
Reference in New Issue
Block a user