在li
中,用户可以选择项目,每个项目都有url属性,最终系统可以将它们存储起来。
在我的例子中,我无法使用 ng-true-value,因为我的复选框的 ng-model 已由于其他逻辑而被占用。
演示 http://plnkr.co/edit/p1fBW3swPHnyBQGBD6Xj?p=preview
我想获取选定的网址并提醒它。
最佳答案
您需要修复复选框绑定(bind):
<input ng-show="showC || checked" type="checkbox" ng-model="checked">
应该是:
<input ng-show="showC || checked" type="checkbox" ng-model="item.checked">
并在getLinks
函数中获取所有选中的项目:
$scope.getlinks = function(){
var urls = '';
angular.forEach($scope.lists, function(item){
if(item.checked === true){
urls += item.url + '\n';
}
});
alert("selected Links: " + urls);
};
关于javascript - 在AngularJS中使用ngcheck获取属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24354841/