0

messageHTML スニペット テンプレートをレンダリングするというカスタム ディレクティブを作成しようとしていますmessage.html。Ruby/Rails と一緒に Angular.js を使用しています。ページをロードすると、無限ループに入ります (SO で読んだものからの再帰ディレクティブである可能性があります)。何か案は?とても有難い!!


app.directive('message', ['$compile', '$templateCache', function factory($compile) {
  'use strict';
  var messageObject = {
    templateUrl: "<%= asset_path('templates/message.html') %>",
    controller: function(){
      UserService.userHash();
    }
    transclude: true,
    restrict: 'E',
    scope: true
  };
  return messageObject;
}]);


message.html

<div ng-transclude>
  MESSAGE WORKS!
</div>


私のディレクティブの使用方法profile.html

<message></message>

詳細については、これが私の Github リポジトリです: https://github.com/natbatwat/shori/tree/master/app/assets/javascripts

4

0 に答える 0