I am new to AngularJS and I'm having trouble with my code. I am attempting to retrieve the attribute value of post-id from my index.html file and display it in the console from my controller.
Here is a snippet from my index.html:
<post-creator post-id="5" category="1"></post-creator>
<script src="components/post-creator/post-creator.component.js"></script>
The code in my post-creator.component.js file looks like this:
function controller($http) {
var model = this;
model.$onInit = function () {
console.log("ID: " + model.postId);
}
module.component("postCreator", {
templateUrl: "components/post-creator/post-creator.template.html",
bindings: {
value: "<"
},
controllerAs: "model",
controller: ["$http", controller]
});