[英]HTML Modal Title attribute AngularJS
I am trying to dynamically set the Title of a 'modal' view using AngularJS (the title should change with respect to some selected user). 我正在尝试使用AngularJS动态设置“模态”视图的标题(标题应针对某些选定用户而更改)。 The HTML is of the form
HTML的形式
<modal title="modalRolesTableTitle" visible="showModalRolesTable"> SOME CONTENT</modal>
In my AngularJS file I have declared both scope variables 在我的AngularJS文件中,我声明了两个作用域变量
$scope.showModalRightsTable = false;
$scope.modalRolesTableTitle = null;
and the visible attribute works fine. 并且visible属性工作正常。 The modalRightsTableTitle variable is being assigned correctly (firebug).
正确分配了modalRightsTableTitle变量(firebug)。
I was hoping someone could explain functionality wise why the visible attribute binds and the title does not and perhaps provide a solution. 我希望有人可以明智地解释功能,为什么可见属性绑定而标题不绑定,也许可以提供解决方案。
Also I have tried ng-attr-title="modalRolesTableTitle" without success (It just displays the text 'modalRolesTableTitle' ). 我也尝试了ng-attr-title =“ modalRolesTableTitle”但没有成功(它只显示文本'modalRolesTableTitle' )。
Always use expression for binding. 始终使用表达式进行绑定。
<modal title="{{modalRolesTableTitle}}" visible="{{showModalRightsTable}}"> SOME CONTENT</modal>
If you are using AngularJS 1.1.4 and above then you can use ng-attr-title 如果您使用的是AngularJS 1.1.4及更高版本,则可以使用ng-attr-title
See this stackoverflow post 看到这个stackoverflow帖子
It's very work around but maybe this solution can be appropriate for you: 可以解决这个问题,但是也许该解决方案可能适合您:
var myEl = angular.element( document.querySelector( '#myModal' ) );
myEl.attr('title',"My tooltip");
of course you have to set: 当然,您必须设置:
<modal id="myModal" title="" visible="{{showModalRightsTable}}"> SOME CONTENT</modal>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.