最近、1.4 にアップグレードしましたが、このホバー ディレクティブの動作に問題があります。
以前は動作していたコード:
angular
.module('tagHoverDirective', []).controller('TagsHover', TagsHover)
.directive('tagsHover', directive);
function directive () {
var directive = {
templateUrl : "popovers/tagsPopovers/tagsHover.html",
restrict: "E",
replace: true,
bindToController: true,
controller: TagsHover
link: link,
scope: {
tag:'=ngModel'
}
};
return directive;
function link(scope, element, attrs) {}
}
TagsHover.$inject = [
'$scope',
'$timeout'];
function TagsHover(
$scope,
$timeout) {
....
1.4 では を使用する必要があり、この部分を次Controller as syntax
のように変更する必要がありました。function directive ()
function directive () {
var directive = {
templateUrl : "popovers/tagsPopovers/tagsHover.html",
restrict: "E",
replace: true,
bindToController: true,
controller: 'TagsHover as tgh',
link: link,
scope: {
tag:'=ngModel'
}
};
return directive;
function link(scope, element, attrs) {}
}
ng-show
マークアップの が機能しなくなりましたが、どうすれば修正できますか? tgh
orは使用していませんthis
。実際には、tag
このディレクティブに渡されるオブジェクトを使用して可視性を設定しています。
<div class="tags-hover-container" ng-show="tag.tagsHoverDisplay">