angularjs - 无法将数据传递给AngularJS中组件内的控制器
问题描述
我有以下组件
componentsModule.component('detailComponent', {
templateUrl: 'detailTemplate.html',
scope: {},
bindings: {
textParam: '='
},
controller: ['$mdDialog', function($mdDialog) {
this.textParam // this is undefined always
}]
});
我正在像这样从其他控制器的对话框中加载模板
$scope.textParam = tParam;
const parentEl = angular.element(document.body);
$mdDialog.show({
template: '<detail-component text-param="$scope.textParam"></detail-component>',
ariaLabel: 'detailComponentDialog',
parent: parentEl
}).then((savedDatails) => {});
如果我使用绑定,@
那么我会$scope.textParam
在我的控制器中得到一个字符串,this.textParam
但是如果我将绑定设置为<
or=
然后我会得到 undefined
解决方案
推荐阅读
- haskell - 使用高阶函数过滤第一个/最后一个
- ruby-on-rails - Rails 中 nil:NilClass 的“[]”的未定义方法
- c - 解析 Windows 和 *nix 系统上的共享库路径
- javascript - React hooks 的奇怪行为:延迟数据更新
- javascript - 元素不可点击,因为另一个元素遮住了它,重叠的元素
- html - 他们不根据屏幕大小调整行和列类
- google-chrome - 如何更改 Chrome 74 中的默认黑色地址栏
- ruby - 使用包含?命令搜索包含数字和字母混合的字符串
- css - 如何为活动的引导程序 4 导航栏项目添加背景颜色
- r - 在 R 中创建具有固定断点的调色板