Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 无法访问redux存储属性_Angular_Redux_Angular Redux - Fatal编程技术网

Angular 无法访问redux存储属性

Angular 无法访问redux存储属性,angular,redux,angular-redux,Angular,Redux,Angular Redux,我无法访问使用angular的redux存储属性 IApp中有两个属性,第一个是接口,第二个是数字 接口AppStoreInterface{ layoutInterface:layoutInterface, 数字:数字 } 我可以毫无问题地访问该号码,但当我尝试访问layoutInterface时,什么都没有发生 这是模块: 导出类AppModule{ 建造师 ngRedux:ngRedux, 公共devTools:DevToolsExtension { const storeEnhancers

我无法访问使用angular的redux存储属性

IApp中有两个属性,第一个是接口,第二个是数字

接口AppStoreInterface{ layoutInterface:layoutInterface, 数字:数字 } 我可以毫无问题地访问该号码,但当我尝试访问layoutInterface时,什么都没有发生

这是模块:

导出类AppModule{ 建造师 ngRedux:ngRedux, 公共devTools:DevToolsExtension { const storeEnhancers=devTools.isEnabled?[devTools.enhancer]:[]; ngRedux.configureStore 减根剂, 初始状态, [], 存储增强剂 ; } } 这是组件:

导出类MainLayoutComponent实现OnInit{ @选择['layoutInterface','sidebarStatus']sidebarStatus$:布尔值; @选择'numero'测试$:编号; 建造师 公共翻译:翻译服务, 公共对话框:MdDialog, 私有ngRedux:ngRedux, 私人行动:裁员 { const browserLang:string=translate.getBrowserLang; translate.usebrowserLang.match/en | es/?browserLang:'en'; this.siteStyle=app; 这个.装箱=; this.align=开始; this.currentLang=en; this.showSettings=false; this.showletton=false; this.userLoggedIn=false; //this.store=this.getStoreService; //this.layoutInterface=this.getLayoutInterface; } } 我做错了什么?

当您使用@select时,您不会从存储中获取值,而是可以观察到该值。要访问该值,您需要订阅该可观察值

@选择['layoutInterface','sidebarStatus']sidebarStatus$:可观察; ^^^^^^^^^^^^^^^^^^^^ @选择“数字”测试$:可观察; ^^^^^^^^^^^^^^^^^^^ 您可以使用异步管道在组件的html模板中直接访问它

边栏 或者,您可以在组件的类中显式订阅它,例如,将值分配给另一个字段,如sidebarStatus:boolean;:

恩戈尼特{ this.sidebarStatus$.subscribesidebarStatus=>this.sidebarStatus; }
老项目!,谢谢@KimKern