0
我是AngularJS的新手不知道我在做什么错误这里是我的代码。基本上我试图从我的index.html中获得post-id的属性值,并从控制器打印到控制台中。AngularJS:从自定义标签获取属性值
在我的index.html:
<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]
});
应该不是你的'bindings'包含'postId'代替'value'? – tanmay
你能举个例子吗? – MTA
补充说,作为答案.. – tanmay