I'm trying to push some info to an array and show it with ng-repeat but for some reason it's not working
This is my controller:
(function () { 'use strict'; angular .module('app.article') .controller('Article', Article); function Article($location) { var vm = this; vm.comments = []; vm.addComment = addComment; function addComment() { vm.comments.push(vm.newComment); vm.newComment = {}; } } })();
Here's the plunkr: https://plnkr.co/edit/jPOJDXoG1vgNfsDzyJAD?p=preview
Thanks for the help
controller as
syntax, and you declared yourng-controller
this way,ng-controller="Article as vm"
, but the data bound items are using$scope
syntax (i.e., they are not referring tovm
at all).