![](/img/trans.png)
[英]How can i set my site tile(<title> equal to blog.title?
[英]How can I make a button title equal to a value on my scope?
我的模板上的ng-repeat div内有一个按钮,我想将其title属性设置为与我的作用域中的值相等,但它显示为字符串而不是值。
模板:
<div ng-repeat="step in steps">
<button title="step.description">Text</button>
</div>
悬停时,上面显示的是文字字符串“ step.description”,而不是我的作用域中的值。 当前,我的控制器上有一个名为step的数组,该数组中的每个step对象都有一个名为“ description”的键,该键设置为不同的字符串。
我认为此链接可以为您提供帮助。 如何使AngularJS绑定到A标签的title属性?
<body ng-app="myApp">
<div ng-controller="myCtrl">
<div ng-repeat="step in steps">
<button ng-attr-title="{{step.description}}">Text</button>
</div>
</div>
</body>
您可以使用ng-attr-title
将鼠标悬停时绑定值。 ng-attr
是AngularJS 1.1.4中的新指令
app.controller('myCtrl', ['$scope', function($scope){
$scope.steps = [
{
description: 'Test1'
},
{
description: 'Test2'
},
{
description : 'Test3'
}
];
这是链接: https : //plnkr.co/edit/Ql4GHSkcuD1r9SywL2mi?p=preview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.