简体   繁体   English

如何使按钮标题等于作用域上的值?

[英]How can I make a button title equal to a value on my scope?

I have a button inside of an ng-repeat div on my template, and I would like to set it's title property to be equal to a value from my scope, but it is showing up as the string, not the value. 我的模板上的ng-repeat div内有一个按钮,我想将其title属性设置为与我的作用域中的值相等,但它显示为字符串而不是值。

template: 模板:

<div ng-repeat="step in steps">
  <button title="step.description">Text</button>
</div>

On hover, the above displays the literal string "step.description" instead of the value from my scope. 悬停时,上面显示的是文字字符串“ step.description”,而不是我的作用域中的值。 Currently my controller has an array on it called steps, and each of the step objects in that array has a key named "description" set to a different string. 当前,我的控制器上有一个名为step的数组,该数组中的每个step对象都有一个名为“ description”的键,该键设置为不同的字符串。

I think this link can help you. 我认为此链接可以为您提供帮助。 How do you get AngularJS to bind to the title attribute of an A tag? 如何使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>

You can use ng-attr-title to bind value on hover. 您可以使用ng-attr-title将鼠标悬停时绑定值。 ng-attr is a new directive in AngularJS 1.1.4 ng-attr是AngularJS 1.1.4中的新指令

 app.controller('myCtrl', ['$scope', function($scope){
        $scope.steps = [
          {
          description: 'Test1'
        },
         {
          description: 'Test2'
        },
         {
          description : 'Test3'
        }

        ];

Here is the link: https://plnkr.co/edit/Ql4GHSkcuD1r9SywL2mi?p=preview 这是链接: https : //plnkr.co/edit/Ql4GHSkcuD1r9SywL2mi?p=preview

我如何设置我的网站图块(<title>等于 blog.title 吗?&lt;/div&gt;</title><div id="text_translate"><p> 好的,所以我正在制作一个小博客网站以供娱乐,我想知道如何设置页面的标题= blog.title(使用nodejs和express)这是我尝试过的,但它不起作用;( .</p><pre> app.get('/blogs/:id', (req, res) =&gt; { const id = req.params.id; Blog.findById(id).then(result =&gt; { res.render('details', { blog: result, title: `Announcement details ${blog.title} ` }); }).catch(err =&gt; { console.log(err); }); });</pre><p> 有没有人有任何可能有效的方法?</p></div> - How can i set my site tile(<title> equal to blog.title?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何设置我的网站图块(<title>等于 blog.title 吗?&lt;/div&gt;</title><div id="text_translate"><p> 好的,所以我正在制作一个小博客网站以供娱乐,我想知道如何设置页面的标题= blog.title(使用nodejs和express)这是我尝试过的,但它不起作用;( .</p><pre> app.get('/blogs/:id', (req, res) =&gt; { const id = req.params.id; Blog.findById(id).then(result =&gt; { res.render('details', { blog: result, title: `Announcement details ${blog.title} ` }); }).catch(err =&gt; { console.log(err); }); });</pre><p> 有没有人有任何可能有效的方法?</p></div> - How can i set my site tile(<title> equal to blog.title? 如何使该值等于localstorage或默认为“ 0” - How can I make the value be equal to localstorage or default to “0” 如何使 javascript 值等于我从 Razor 代码收到的值 - How to make a javascript value equal to the value that I receive from my Razor code 如何在更改值而不是单击按钮时运行函数? - How can I make my function run when a value is changed instead of when the button is clicked? 当网格发生变化时,如何使网格内的所有 div 具有相同的大小? - How can I make all my divs inside a grid have equal size when the grid changes? 如何使threejs中的相机旋转y等于360? - How can i make my camera rotation y in threejs equal to 360? 如何为我的网站创建一个类似“ Digg it”的按钮? - How can I make a button like 'Digg it' for my website? 如何使我的分页按钮处于活动状态? - How can i make my pagination button active? 如何让我的按钮调用 GIF 旋转? - How can I make my button call a rotation of GIFs? 如何让我的 javascript 表单重置按钮工作? - How can I make my javascript form reset button work?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM