加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 使用抽象状态的目的是什么?

发布时间:2020-12-17 07:38:20 所属栏目:安全 来源:网络整理
导读:我正在研究我的教程AngularUI项目. 我读了所有关于状态,嵌套状态和抽象状态. 问题是我不明白为什么,何时应该使用抽象状态? Abstract state does mean the state that you wrote can’t be accessible directly. Abstract states still need their own for t
我正在研究我的教程AngularUI项目.
我读了所有关于状态,嵌套状态和抽象状态.
问题是我不明白为什么,何时应该使用抽象状态?

Abstract state does mean the state that you wrote can’t be accessible
directly. Abstract states still need their own for their children to plug into.

当我们加载孩子的状态时,它被调用.您可以使用抽象状态来定义页面的一些初始模式,假设您可以以任何社交媒体网站为例,您希望显示用户个人资料社交页面.为此,你可以拥有一个抽象的状态,它将具有url:“”&具有您的页面的基本布局.像标题,内容和页脚命名视图.标题&页脚命名视图将由抽象状态&那么孩子会定义内容取决于显示哪个模块. / profile将显示userProfile.html& / social将显示一个用户social社交页面.

配置

app.config(function($stateProvider){
  $stateProvider.state("app":
  {
    url: "",//you can have the default url here..that will shown before child state url
    abstract: true,views: {
       '': {
          templateUrl: 'layout.html',controller: 'mainCtrl'
       },'header': {
          templateUrl: 'header.html'
       },'footer': {
          templateUrl: 'footer.html'
       }
    },resolve: {
       getUserAuthData: function(userService){
           return userService.getUserData();
       }
    }

  })
  .state("app.profile": {
      'content@app': {
          templateUrl: 'profile.html',controller: 'profileController'
      }
  })
  .state("app.social": {
      'content@app': {
          templateUrl: 'social.html',controller: 'socialController'
      }
  })
})

抽象的其他主要特征是您可以有一个共同的解决方案,通过数据提供继承的自定义数据,供儿童状态或事件监听器使用.也可以有OnEnter& OnExit在它之前确保事情在加载状态&同时离开国家

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读