javascript - 在标记中获取 AngularJS 对象属性名称

标签 javascript angularjs

假设我有一个对象:

$scope.Golovkin = {
    id:12,
    Like:0,
    Dislike:0,
    url:"https://twitter.com/GGGBoxing"
};

在 View 中我有一个按钮:

<input type="button" value="Like" ng-click="incrementLikes(Golovkin)" />

如何将按钮的 value 替换为 $scope.Golovkin.Like 的属性名称作为字符串?

最佳答案

<input type="button" ng-model="Golovkin.Like" ng-click="incrementLikes(Golovkin)" />

关于javascript - 在标记中获取 AngularJS 对象属性名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38188126/

相关文章:

javascript - contenteditable div 中的 n gram 突出显示

javascript - 添加动态元素时进行 AngularJS 表单验证

javascript - 如何在没有双向绑定(bind)的情况下将 ngModel 传递给 AngularJS 组件?

angularjs - 带有新行中断的水平 ng-repeat(er)

javascript - 我不能在 Nuxt.js/vue.js 中使用第三方组件

javascript - 如何创建 Facebook 应用程序并将其连接到我的旧 Facebook 页面

javascript - Backbone : using partial fetch versus 1 collection through the whole lifespan of the application

javascript - 在 angularjs 中创建自定义控件的推荐方法

javascript - angular ui grid 单过滤器 + cellfilter

angularjs - Angular UI Router - 如何在代码中使用 $uiView Scroll