繁体   English   中英

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

[英]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

我如何设置我的网站图块(<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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM