2017-05-24 140 views
0

我有一个需要密码的模式窗口。如果输入的是空的话就不会有错误,我要显示工具提示时有错误AngularJS Tooltip tooltip-is-open not working

<input type='password' class='form-control' id='password' ng-model='user.password' uib-tooltip='{{error_msg}}' tooltip-placement='right' tooltip-trigger='none' tooltip-is-open='true' tooltip-class='tooltip_error' tooltip-enable='{{error}}' autofocus> 

目前的情况是,如果没有错误,则提示不显示在所有。一旦出现错误,它将显示错误消息,但我必须将鼠标悬停在文本框上以显示工具提示。与此同时,我已将tooltip-is-open设置为true以对其进行测试,但目前无法使用。

任何想法?

回答

0

从您的tooltip-enable指令中删除interpolation operators({{}})使其起作用,因为它指向scope属性。

改变你的代码,如:

<input type='password' class='form-control' id='password' ng-model='user.password' uib-tooltip='tootltip text : {{error_msg}}' tooltip-placement='right' tooltip-trigger='none' tooltip-is-open='true' tooltip-class='tooltip_error' tooltip-enable='error' autofocus> 

更新uib-tooltip指令采用的文本输入,所以我们需要把插值算到它。 Read more

看到这个plunker

+0

当我删除了'{}',它只是打印出“ERROR_MSG”,但布尔结果为'提示,enable'不工作,因为它应该。 –

+0

@ J.Do:您必须将'error_msg'作为$ scope属性,例如像'$ scope.error_msg =“密码中的错误'' – anoop

+0

是的,这就是我以前的样子,但它只在用{{} '。我仍然需要将鼠标悬停在文本框上以显示工具提示。 –