Angular传多个值到controller

页面

 <a ui-sref="work-record-glxss-car-person(
 {id:vm.workRecord.person.id,workRecordId:vm.workRecord.id})
 " >a>

state

  .state('work-record', {
            parent: 'work-record',
            url: '/persons/{id}?workRecordId'
            views: {
                'content@': {
                    templateUrl: 'app/entities/plugin/plugin-glxss-info-person.html',
                    controller: 'PluginGlxssPersonInfoController',
                    controllerAs: 'vm'
                }
            },
            resolve: {
                translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) {
                    $translatePartialLoader.addPart('workRecord');
                    return $translate.refresh();
                }],
                entity: ['$stateParams', 'Person', function ($stateParams, Person) {
                    return Person.get({id: $stateParams.id}).$promise;
                }],
                workRecordId: ['$stateParams', function ($stateParams) {
                    return $stateParams.workRecordId;
                }],**重点内容**

controller

//我们需要在Controller中接收WorkRecordID的值用于才另外页面的使用
($scope, $state, $rootScope, $stateParams, previousState, entity, workRecordId) {

在传值中注意url中的参数
在resolve中注意各个entity,获取stateParams中的参数

你可能感兴趣的:(angulerJS)