2017-05-24 138 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

是的,這就是我以前的樣子,但它只在用{{} '。我仍然需要將鼠標懸停在文本框上以顯示工具提示。 –