diff --git a/modules/angular1_router/src/ng_outlet.ts b/modules/angular1_router/src/ng_outlet.ts index ea4e723408..6913e55633 100644 --- a/modules/angular1_router/src/ng_outlet.ts +++ b/modules/angular1_router/src/ng_outlet.ts @@ -213,6 +213,10 @@ function ngLinkDirective($rootRouter, $parse) { let link = attrs.ngLink || ''; function getLink(params) { + if (!params) { + return; + } + navigationInstruction = router.generate(params); scope.$watch(function() { return router.isRouteActive(navigationInstruction); }, diff --git a/modules/angular1_router/test/ng_link_spec.js b/modules/angular1_router/test/ng_link_spec.js index 90fb750b2b..12ce06c92e 100644 --- a/modules/angular1_router/test/ng_link_spec.js +++ b/modules/angular1_router/test/ng_link_spec.js @@ -140,6 +140,18 @@ describe('ngLink', function () { navigateTo('/'); expect(elt.find('a').attr('class')).toBe('ng-link-active'); }); + + it('should not add a href if link attributes are undefined', function () { + setup({baseHref: baseHref, html5Mode: html5Mode, hashPrefix: hashPrefix}); + configureRouter([ + { path: '/a', component: 'oneCmp' }, + { path: '/b', component: 'twoCmp', name: 'Two' } + ]); + + var elt = compile('link | outer {
}'); + navigateTo('/a'); + expect(elt.find('a').hasAttr('href')).toBeFalsy(); + }); } function registerComponent(name, template, controller) {