angularjs - 为什么'<'绑定的 currentValue 未定义当我作为 Angular 中的文字字符串传递时
问题描述
你好我有一个绑定说itemType:
这就是我在组件中定义它的方式:
bindings: {
itemType: '<?',
}
现在由于某种原因,当我将它作为文字字符串而不是属性值传递时,该值没有传递,这就是我的意思,假设我有一个控制器:
someController = function someController( $scope) {
var self = this;
self.itemType = 'someString';
在职的:
<some-component>
open-id="singleSelect"
item-type="ctrl.itemType"
//..
itemType.currentValue = 'someString'
不工作:
<some-component>
open-id="singleSelect""
item-type="someString"
//..
itemType.currentValue = undefined
解决方案
为使用单向('<')
绑定绑定的组件属性提供文字字符串时,请使用引号:
<some-component
open-id="singleSelect"
̶i̶t̶e̶m̶-̶t̶y̶p̶e̶=̶"̶s̶o̶m̶e̶S̶t̶r̶i̶n̶g̶"̶ ̶
item-type="'someString'" >
</some-component>
否则someString
被评估为属性标识符。它绑定undefined
是因为该属性在范围内不存在。
推荐阅读
- python - 如何从 keras 中的图像批处理数据集中输出图像
- flutter - 无法在命令行上运行颤振
- html - 如何通过 specflow3.4.3 生成 HTML 报告?
- python - 如何通过在 tkinter 中选择两个下拉菜单选项来获取输出结果
- sql - 如何使用 Python 将 Dataframe 放入 SQL where 子句中?
- spring - Spring boot 找不到模板位置调试模式
- c++ - 当我关闭文件资源管理器时,我的 C++ 程序被删除
- javascript - 为什么我的这个 React 代码会出现无限循环?
- javascript - 从 json 文件读取时,如何返回对象而不是数组中的对象?
- kubernetes - 504 使用多个复制的 pod 访问 Web 服务。单吊舱没有错误