角度が非常に新しいです。この指令がなぜ機能しないのか理解してください。どのコンセプトを学ぶべきかを指摘してください。私は、文字列としてテンプレートを書き出していたが、それは非常に醜いと私は別のHTMLファイルに入れたいとき指令:コントローラーは機能ではありません
ディレクティブはを働いていました。 index.htmlを
<div message-modal trigger="trigger_message_modal"></div>
で
エラーメッセージ:$scope.trigger_message_modal is not a function
app.module.directive('messageModal', function ($compile) {
return {
scope: {
trigger: "=trigger"
},
controller: ['$scope', '$element', '$attrs', '$timeout', function ($scope, $element, $attrs, $timeout) {
$scope.trigger = function(title, message, modal_class, color, auto_hide){
$scope.message = message;
$scope.modal_class = modal_class;
$scope.color = color;
$scope.title = title;
$('#messageWell').modal('show');
if(auto_hide == true){
$timeout(function(){
$('#messageWell').modal('hide');
}, 1000)
}
};
}],
restrict: "E",
templateUrl :"well.html"
};
});
'$ scope.trigger_message_modal'はどこからトリガーされましたか?ディレクティブコントローラがインスタンス化される前に関数がトリガされるタイミング問題である可能性がありますか? – jchen86