I have a directive in angular that resembles this:
.directive('forexample', function() {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
elm.on('click', function() {
scope.$apply(function () {
ctrl.$setViewValue('value');
Called from something like:
<button forexample ng-model="mymodel">Do It</button>
So obviously
$scope.mymodel; // equals value
What I want is to push('value'); to the model from the directive so in the end after clicking "Do It" a few times, you'd get:
$scope.mymodel; // equals array('value,'value','value');