你如何让AngularJS绑定到A标签的title属性?
目的是让产品名称出现在缩略图的工具提示中。
浏览器不会从“ng-title”或“ng-attr-title”创建工具提示。 我们使用AngularJS 1.0.7版本。 例如, 1。 代码:< a title =“{{product.shortDesc}}”...> 预期结果:< a title =“Canon Powershot XS50 12MB数码相机”...> 实际结果:< a title =“{{product.shortDesc}}”...>我们在工具提示中得到不需要的大括号。 例如, 2。 代码:< a ng-attr-title =“{{product.shortDesc}}”...> 预期结果:< a title =“Canon Powershot XS50 12MB数码相机”...> 实际结果:< a ng-attr-title =“Canon Powershot XS50 12MB数码相机”...> 我们不会得到一个简单的标题attirbute,我们也没有工作的工具提示。
看起来ng-attr是AngularJS 1.1.4中的一个新指令,你可以在这种情况下使用。
https://github.com/angular/angular.js/commit/cf17c6af475eace31cf52944afd8e10d3afcf6c0 但是,如果你留在1.0.7,你可以写一个自定义指令镜像的效果。 <!-- example --> <a ng-attr-title="{{product.shortDesc}}"></a> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |