Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot
  1. Firstly, we are using the ui-router so we cannot use the <div ng-controller="TabsCtrl">. We do have states now, and each state can have more views, which DO have their own controllrs (i.e. controller belongs to view beeing part of a state)

  2. As just explained, views do have controller (exactly one). Not states - they do NOT have controllers. So I moved the controller definition from state, into view...

     .state('home.summary', { url: '/summary', // NOT HERE views: { 'summary': { ... controller: 'SummaryCtrl', } } }) .state('home.summary.detail', { url: '/detail/:id', // NOT HERE views: { 'detail@home': { ... controller: 'DetailCtrl', 
  3. resolve of the parent and child should have different names. I changed the child resolve like this (see mainyl the name load2 instead of load):

     .state('home.summary.detail', { url: '/detail/:id', views: { 'detail@home': { ... resolve: { load2: function($rootScope, $stateParams) { return 'loaded child with param ' + $stateParams.id ; } }, } 
  4. Even if we want to have that: ui-view cannot be inside of the repeater. Well it can, but it would simply mean that the state view would be placed there as many times as repeated (but see the linkslinks below .. how to do that)

  1. Firstly, we are using the ui-router so we cannot use the <div ng-controller="TabsCtrl">. We do have states now, and each state can have more views, which DO have their own controllrs (i.e. controller belongs to view beeing part of a state)

  2. As just explained, views do have controller (exactly one). Not states - they do NOT have controllers. So I moved the controller definition from state, into view...

     .state('home.summary', { url: '/summary', // NOT HERE views: { 'summary': { ... controller: 'SummaryCtrl', } } }) .state('home.summary.detail', { url: '/detail/:id', // NOT HERE views: { 'detail@home': { ... controller: 'DetailCtrl', 
  3. resolve of the parent and child should have different names. I changed the child resolve like this (see mainyl the name load2 instead of load):

     .state('home.summary.detail', { url: '/detail/:id', views: { 'detail@home': { ... resolve: { load2: function($rootScope, $stateParams) { return 'loaded child with param ' + $stateParams.id ; } }, } 
  4. Even if we want to have that: ui-view cannot be inside of the repeater. Well it can, but it would simply mean that the state view would be placed there as many times as repeated (but see the links below .. how to do that)

  1. Firstly, we are using the ui-router so we cannot use the <div ng-controller="TabsCtrl">. We do have states now, and each state can have more views, which DO have their own controllrs (i.e. controller belongs to view beeing part of a state)

  2. As just explained, views do have controller (exactly one). Not states - they do NOT have controllers. So I moved the controller definition from state, into view...

     .state('home.summary', { url: '/summary', // NOT HERE views: { 'summary': { ... controller: 'SummaryCtrl', } } }) .state('home.summary.detail', { url: '/detail/:id', // NOT HERE views: { 'detail@home': { ... controller: 'DetailCtrl', 
  3. resolve of the parent and child should have different names. I changed the child resolve like this (see mainyl the name load2 instead of load):

     .state('home.summary.detail', { url: '/detail/:id', views: { 'detail@home': { ... resolve: { load2: function($rootScope, $stateParams) { return 'loaded child with param ' + $stateParams.id ; } }, } 
  4. Even if we want to have that: ui-view cannot be inside of the repeater. Well it can, but it would simply mean that the state view would be placed there as many times as repeated (but see the links below .. how to do that)

added 197 characters in body
Source Link
Radim Köhler
  • 124.1k
  • 48
  • 243
  • 343
  1. Firstly, we are using the ui-router so we cannot use the <div ng-controller="TabsCtrl">. We do have statesstates now, and each statestate can have more viewsviews, which DO have their controlelrsown controllrs (i.e. controller belongs to view beeing part of a state)

  2. As just explained, viewsviews do have controllers, notcontroller (exactly one). Not states, so - they do NOT have controllers. So I moved the controller definition from state, into view...

     .state('home.summary', { url: '/summary', // NOT HERE views: { 'summary': { ... controller: 'SummaryCtrl', } } }) .state('home.summary.detail', { url: '/detail/:id', // NOT HERE views: { 'detail@home': { ... controller: 'DetailCtrl', 
  3. resolve of the parent and child should have different names sonames. I changed the child resolve lieklike this (see the load2 instead of load)(see mainyl the name load2 instead of load):

     .state('home.summary.detail', { url: '/detail/:id', views: { 'detail@home': { ... resolve: { load2: function($rootScope, $stateParams) { return 'loaded child with param ' + $stateParams.id ; } }, } 
  4. Even if we want to have that...: ui-view cannot be inside of the repeater. Well it can, but it would simply mean that the state view would be placed there as many times as repeated I moved thes ui-view outside of the repeater:

    {{tab.title}}

  5. // moved outside of repeater
  6. if we target (but see the view not directly in parent, we havelinks below .. how to use absolute naming, that's why I used this:do that)

     .state('home.summary', { url: '/summary', views: { 'summary': { // ok name, while direct parent is home .... } } }) .state('home.summary.detail', { url: '/detail/:id', views: { 'detail@home': { // we have to add @home to say that the target .... // is in a home state not in our parent } } 

I moved thes ui-view outside of the repeater:

<li tab ng-repeat="tab in tabs track by tab.id" active="tab.active" select="tab.select()"> <span tab-heading>{{tab.title}}</span> </li> <hr /> <div ui-view="detail"></div> // moved outside of repeater 
  1. if we target the view, which is not placed directly in its parent, we have to use absolute naming, that's why I used this:

     .state('home.summary', { url: '/summary', views: { 'summary': { // ok name, while direct parent is home .... } } }) .state('home.summary.detail', { url: '/detail/:id', views: { 'detail@home': { // we have to add @home to say that the target .... // is in a home state not in our parent } } 

Few very interseting reading (I'd say) to really spend some time with(I'd say):

  1. Firstly, we are using the ui-router so we cannot use the <div ng-controller="TabsCtrl">. We do have states now, and each state can have more views, which DO have their controlelrs

  2. As just explained, views do have controllers, not states, so I moved the controller definition from state, into view

     .state('home.summary', { url: '/summary', // NOT HERE views: { 'summary': { ... controller: 'SummaryCtrl', } } }) .state('home.summary.detail', { url: '/detail/:id', // NOT HERE views: { 'detail@home': { ... controller: 'DetailCtrl', 
  3. resolve of the parent and child should have different names so I changed the child resolve liek this (see the load2 instead of load):

     .state('home.summary.detail', { url: '/detail/:id', views: { 'detail@home': { ... resolve: { load2: function($rootScope, $stateParams) { return 'loaded child with param ' + $stateParams.id ; } }, } 
  4. Even if we want to have that... ui-view cannot be inside of the repeater. Well it can, but it would simply mean that the state view would be placed there as many times as repeated I moved thes ui-view outside of the repeater:

    {{tab.title}}

  5. // moved outside of repeater
  6. if we target the view not directly in parent, we have to use absolute naming, that's why I used this:

     .state('home.summary', { url: '/summary', views: { 'summary': { // ok name, while direct parent is home .... } } }) .state('home.summary.detail', { url: '/detail/:id', views: { 'detail@home': { // we have to add @home to say that the target .... // is in a home state not in our parent } } 

Few very interseting reading (I'd say) to really spend some time with:

  1. Firstly, we are using the ui-router so we cannot use the <div ng-controller="TabsCtrl">. We do have states now, and each state can have more views, which DO have their own controllrs (i.e. controller belongs to view beeing part of a state)

  2. As just explained, views do have controller (exactly one). Not states - they do NOT have controllers. So I moved the controller definition from state, into view...

     .state('home.summary', { url: '/summary', // NOT HERE views: { 'summary': { ... controller: 'SummaryCtrl', } } }) .state('home.summary.detail', { url: '/detail/:id', // NOT HERE views: { 'detail@home': { ... controller: 'DetailCtrl', 
  3. resolve of the parent and child should have different names. I changed the child resolve like this (see mainyl the name load2 instead of load):

     .state('home.summary.detail', { url: '/detail/:id', views: { 'detail@home': { ... resolve: { load2: function($rootScope, $stateParams) { return 'loaded child with param ' + $stateParams.id ; } }, } 
  4. Even if we want to have that: ui-view cannot be inside of the repeater. Well it can, but it would simply mean that the state view would be placed there as many times as repeated (but see the links below .. how to do that)

I moved thes ui-view outside of the repeater:

<li tab ng-repeat="tab in tabs track by tab.id" active="tab.active" select="tab.select()"> <span tab-heading>{{tab.title}}</span> </li> <hr /> <div ui-view="detail"></div> // moved outside of repeater 
  1. if we target the view, which is not placed directly in its parent, we have to use absolute naming, that's why I used this:

     .state('home.summary', { url: '/summary', views: { 'summary': { // ok name, while direct parent is home .... } } }) .state('home.summary.detail', { url: '/detail/:id', views: { 'detail@home': { // we have to add @home to say that the target .... // is in a home state not in our parent } } 

Few very interseting reading (I'd say):

added 369 characters in body
Source Link
Radim Köhler
  • 124.1k
  • 48
  • 243
  • 343

Few very interseting reading (I'd say) to really spend some time with:

Few very interseting reading (I'd say) to really spend some time with:

Source Link
Radim Köhler
  • 124.1k
  • 48
  • 243
  • 343
Loading