我正在关注Ngrx教程,但不了解一个概念 请让我知道我错了 Hide_product_code没有响应。我想我缺少了什么
this.store.pipe(select('products')).subscribe(
products => {
if(products){
this.displayCode = products.showProductCode;
this.displayCode = products.hideProductCode;
}
}
)
}
点击(检查表格)
checkChanged(value: boolean): void {
if(value = true){
this.store.dispatch({
type:'SHOW_PRODUCT_CODE',
showProductCode:value
})
}
else {
this.store.dispatch({
type:'HIDE_PRODUCT_CODE',
hideProductCode:value
})
this.displayCode = value;
}
}
Product.reducer.ts
export function reducer(state, action) {
switch (action.type) {
case 'SHOW_PRODUCT_CODE':
console.log("shoow product code", action);
return {
...state,
showProductCode: true
};
case 'HIDE_PRODUCT_CODE':
return {
...state,
showProductCode: false
};
default:
return state;
}
}
请找到指向stackblitz的链接 https://stackblitz.com/edit/state-managamenrt?file=src/app/app.module.ts