私はhtmlを持っています。htmlから変数AngularJSに変数を渡すにはどうしたらいいですか?
<div class="dashboardTr" ng-repeat="post in posts">
<modal-dashboard header="Success" body="post.ID" id="success"></modal-dashboard>
</div>
と、このディレクティブ:
app.directive('modalDashboard', function() {
return {
restrict: 'E',
scope: {
header: '@header',
body: '=',
id: '@id'
},
templateUrl: '/modalDashboard.html'
}
});
ポップアップの新しいHTMLは次のとおりです。
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">{{ header }}</h4>
</div>
<div class="modal-body">
<p>{{ body }}</p>
</div>
</div>
それは動作しません。私はこれを持っています。 bodyプロパティに文字列を渡すと、それが動作します。どうしたの? 別の指令の中にあります。それは問題だろうか? ありがとうございました!
を使用すると、ランダムな単語とはどういう意味ですか?ランダムな言葉をどこに渡していますか? – Avinash
@Avinash A string – Ary
'body'と' header'の場合はDOMと競合していると思うので、それを変更してみてください。 – Hearty