AngularUI-Router: Übergeben Sie u, rl-Parameter an den Status 'abstract', während Sie den untergeordneten Status aufrufen

Ich möchte auf den URL-Parameter ($ stateParam) in einem abstrakten Zustand zugreifen, während ich einen untergeordneten Zustand aufrufe. Ich bin gespannt, wie das geht. Code einPlunker auch

$stateProvider
    .state('contacts', {
        abstract: true,

        //my whole point is to get the id=1 here :(

        url: '/contacts/:id',
        templateUrl: function($stateParams){
            console.log("Did i get the child's parameter here? " + $stateParams.id)
            return 'contacts' + $stateParams.id + '.html'; //this will have a ui-view in it which will render its detail.
        }
    })

    .state('contacts.detail', {
        url: '/:id',
        // loaded into ui-view of parent's template
        templateUrl: 'contacts.detail.html',
        controller: function($scope, $stateParams){
          $scope.person = $scope.contacts[$stateParams.id];
        },
        onEnter: function(){
          console.log("enter contacts.detail");
        }
    })
})

`

und ich nenne es als

<a ui-sref="contacts.detail({id: 1})">My first contact<a>

Warum mache ich das so? Da meine Vorlage vom Server für verschiedene Kontakte unterschiedlich ist, ist das Layout unterschiedlich.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage