angularjs - Index is getting injected into itself instead of templateUrl -


edit: solution @ bottom of question.

so, difficult provide code, because behavior happening in context of large project, instead of routes showing templateurl route, index getting injected index, , index doesn't show templateurl either.

i'm trying replace foundation apps routing vanilla ui-router. i've followed steps here strip out foundation's routing, seems i'm still having kind of conflict.

this absolutely driving me nuts. config looks this:

.config(['$stateprovider', $urlrouterprovider', function($stateprovider, $urlrouterprovider) {  $urlrouterprovider.otherwise('/');   $stateprovider    .state('/', {      url: '/',      templateurl: "<div><h1>test</h1></div>"    })  ; }]) 

it doesn't matter put in templateurl, replaced index.html, , end index inside index.

any appreciated!

solution:

it looks like, whatever reason, ui-router injects index if path template doesn't resolve. (it may inject parent template, in case index, may different in other situations, i'm unsure. check out link javier vargas provided in comment answer more info.) if have:

.state('home', {   url: '/home',   templateurl: 'incorrect path' } 

the result in context of situation state injects index.html.

for specific problem of routing ui-router within context of foundation apps project, path templates /templates/myhtmlfiles.html, state this:

.state('home', {   url: '/home',   templateurl: '/templates/home.html' } 

and because foundation apps' routing plugin treats "templates" root, ui-router treats working dir root (this might "client", "app", etc, in context of foundation apps install 1 dir above /templates, have add path.)

thanks answers below helped me sort out why index getting plopped ui-view div (to restate, incorrect path template. if you're having problem, check route. if need test, replace templateurl: template: 'test' , see if gets plunked in.)

shouldn't using template besides templateurl?


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -