将对象值传递给指令而不是任何其他数据变量
I am trying to customize this working http://jsfiddle.net/markcoleman/JNqqU/ ,in current working fiddle directly object is assigned . where i am trying to change it to $scope.obj.items . passing object to directive is not working .
我正在尝试自定义这个工作http://jsfiddle.net/markcoleman/JNqqU/,在当前工作小提琴直接对象被分配。我试图将其更改为$ scope.obj.items。将对象传递给指令不起作用。
do i need to write some $watch fo r the variable ??? i am getting dynamic value that's why i am trying to pass Object value with this .
我需要写一些$ watch变量???我正在获得动态值,这就是为什么我试图用这个传递Object值。
Code ::
代码::
<a href="#" pop-over items="obj.items", title="Mode of transport">
Show Pop over</a>
javascript Directive part ::
javascript指令部分::
scope: {
items: '=',
title: '@'
}
Any suggestion ,
任何建议,
I am trying Below Fiddle http://jsfiddle.net/JNqqU/652/
我正在尝试下面的小提琴http://jsfiddle.net/JNqqU/652/
4 个解决方案
#1
2
You can change your controller to this:
您可以将控制器更改为:
bootstrap.controller('maincnt', function ($scope) {
$scope.obj = { // declare the scope object here with a blank items
items: []
};
$scope.updateitem = function () {
alert('scope update called');
$scope.obj.items = ['car', 'truck', 'plane', 'bike']; // now update here
}
});
Checkout fiddle.
结账小提琴。
更多相关文章
- Angularjs指令ng-hide在单元格模板中不对网格数据的更改进行绑定
- 当开始使用数据-*时,无法识别AngularJS指令
- $ postLink的角度组件/指令运行得太早
- element.replaceWith在自定义指令的链接中仅在第一次调用时工作
- Mac下MySQL-python安装及EnvironmentError: mysql_config not fo
- Python 2.6.2中的ElementTree处理指令支持?
- 通过指令“ps -l”查看进程信息
- 常见压缩格式的区别,及 Linux 下的压缩相关指令
- Linux学习笔记_1.Linux常见指令