angularjs - angular 1.5 Routing using $routeConfig vs $router.config -


i working more new angular router. of posts see around 2.0 should similar.

however, have been working through source code https://github.com/brandonroberts/angularjs-component-router/tree/master/lib.

i have noticed there use of $routerrootcomponent. have been trying figure out if can used default starting place components. however, getting error

error: component "root" has no route config. 

i believed setting routeconfig correctly in controller component ...

(function() {     'use strict;'     angular         .module('componenttutorial.home')         .value('$routerrootcomponent', 'componenttutorial.home')         .component('home',homecomponentoptions);          var homecomponentoptions = {              bindings: {                   title: '@'             },             templateurl: 'app/home/home.html',             controller: homecontroller               }          function homecontroller ($router) {             $routeconfig: [                 {path: '/home...', name: 'home', useasdefault: true}             ];         } })(); 

my desire keep routes close home controller. had set directive , hosted of routes in 1 directive's controller, can confusing set child routes , difficult find.

-ex

unction appcontroller($router) {         console.log('configuring routers');          $router.config([             {                 path: '/',                 component: 'home',                 name: 'home'             },             {                 path: '/**',                 component: 'notfound',                 name: 'notfound'             },             {                 path: '/about',                 component: 'about',                 name: 'about'             }          ]);     } 

any insight setting components routes hugely appreciated.

(function() {     'use strict;'     angular         .module('componenttutorial.home', ['ngcomponentrouter'])         .value('$routerrootcomponent', 'app')         .component('home',homecomponentoptions);          var homecomponentoptions = {              bindings: {                   title: '@'             },             templateurl: 'app/home/home.html',             controller: homecontroller               }          function homecontroller ($router) {             $routeconfig: [                 {path: '/home...', component: 'home', name: 'home', useasdefault: true}             ];         } })(); 

added 'ngcomponentrouter' module dependencies. changed second param of value custom element added inside app(componenttutorial.home). see below html example. thirdly add new property component homecontroller $routeconfig. component value should components name.

html

 <app></app> 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -