0
私はAngularJSの初心者です。ここで間違っているのは私のコードです。基本的に私は私のindex.htmlからポストIDの属性値を取得し、私のコントローラからコンソールでそれを印刷しようとしています。私のindex.htmlでAngularJS:カスタムタグから属性値を取得します。
:
<post-creator post-id="5" category="1"></post-creator>
<script src="components/post-creator/post-creator.component.js"></script>
ポストcreator.component.js:
function controller($http) {
var model = this;
model.$onInit = function() {
console.log("id again:" + model.postId);
}
module.component("postCreator", {
templateUrl: "components/post-creator/post-creator.template.html",
bindings: {
value: "<"
},
controllerAs: "model",
controller: ["$http", controller]
});
は、あなたの '' postId'の代わりに、[値]を含めるbindings'ではないでしょうか?このような – tanmay
私に例を教えてもらえますか? – MTA
答えとして追加しました.. – tanmay