私はテンプレート/ templateURLに適用できますが、現在、コンテンツはアプリケーションの別の場所から読み込まれます。ajaxコンテンツへの角度js指示の適用方法は?
JSbin:http://jsbin.com/imuseb/1/
HTML
<html ng-app="app">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
</head>
<body>
<div alert>here</div>
</body>
</html>
JSコード:
var app = angular.module('app', []);
app.directive('alert', function(){
return {
link: function (scope, element, attrs) {
element.on("click", function(){
alert("here");
});
}
};
});
$(function(){
$("body").append("<div alert>here too</div>");
});
これまでに何を試みましたか?いくつかのサンプルコードを提供できますか? – tschiela
いくつかのコードが追加されました... –