发表于: 2017-04-19 01:38:23

2 1327


今天完成的事情:任务8搜索功能,分页功能实现,初步完成任务8,添加了删除功能。

明天计划的事情:任务9图片上传功能,公司信息编辑功能,新增能公司功能
遇到的问题:

请求删除
收获:

$stateParams:状态参数的理解:

$stateParams服务的是一个对象,包含url中没课参数的键/值,$stateParams可以为控制器或者url提供的各个部分,且必须和一个控制器相关,并且$stateParams中的键值对也必须在控制器的url中有定义,

/ 如果状态中 url 属性是:
url: '/users/:id/details/{type}/{repeat:[0-9]+}?from&to'

// 当浏览
'/users/123/details//0'

// $stateParams 对象将是
{ id:'123', type:'', repeat:'0' }

// 当浏览
'/users/123/details/default/0?from=there&to=here'

// $stateParams 对象将是
{ id:'123', type:'default', repeat:'0', from:'there', to:'here' }

使用$stateParams的两个陷阱:

有当状态被激活并且状态的所有依赖项都被注入时,$stateParams对象才存在。这代表你不能再状态的resolve函数中使用$stateParams对象,可以使用$state.current.params来代替。

$stateProvider.state('contacts.detail', {  
  resolve: {
     someResolve: function($state){
        //*** 不能在这里使用 $stateParams , the service is not ready ***//
        //*** 使用 $state.current.params 来代替 ***//
        return $state.current.params.contactId + "!"
     };
  },
  // ...
})
  •      在状态控制器中,$stateParams对象只包含那些在状态中定义的参数,因此你不能访问在其他状态或者祖先状态中定义的参数。
  • $stateProvider.state('contacts.detail', {
      url: '/contacts/:contactId',  
      controller: function($stateParams){
         $stateParams.contactId  //*** Exists! ***//
      }
    }).state('contacts.detail.subitem', {
      url: '/item/:itemId',
      controller: function($stateParams){
         $stateParams.contactId //*** 注意! DOESN'T EXIST!! ***//
         $stateParams.itemId //*** Exists! ***//  
      }
    })



返回列表 返回列表
评论

    分享到