AngularJSディレクティブから属性にアクセスする
私のAngularJSテンプレートには、次のようなカスタムHTML構文が含まれています。 <su-label tooltip="{{field.su_documentation}}">{{field.su_name}}</su-label> それを処理するディレクティブを作成しました: .directive('suLabel', function() { return { restrict: 'E', replace: true, transclude: true, scope: { title: '@tooltip' }, template: '<label><a href="#" rel="tooltip" title="{{title}}" data-placement="right" ng-transclude></a></label>', link: function(scope, element, attrs) { if (attrs.tooltip) { element.addClass('tooltip-title'); } }, } }) を実行するとGoogle ChromeのJavaScriptコンソールから属性が表示されても、attrs.tooltip常に返される式を除いて、すべてが正常に機能します。undefinedtooltipconsole.log(attrs) なにか提案を? 更新:Artemによってソリューションが提供されました。それはこれを行うことにありました: link: function(scope, element, attrs) { attrs.$observe('tooltip', …