In view I defined a button like ->
<button class="btn btn-default" ng-click="reset(path)">Reset</button>
And I want this function to reset an array which has been defined inside the controller.
Controller Code
app.controller('mainCtrl',function(NgMap,$scope){
var vm = this;
$scope.path = [];
vm.addMarkerAndPath = function(event) {
$scope.path.push([event.latLng.lat(), event.latLng.lng()]);
console.log($scope.path);
};
$scope.reset = function(){
$scope.path.length=0;
$scope.path =[]; // also tried this but didn't work
}
});
Html Code
<div class="panel panel-default" ng-controller="srmmobileHoardingCtrl as vm">
<div class="panel-heading">
Save Path for hoarding Advertisement
</div>
<ng-map zoom="7" center="41.879535, -87.624333" on-click="vm.addMarkerAndPath()">
<shape name="polyline" id="foo"
path="{{path}}"
stroke-color="#FF0000"
stroke-opacity="1.0"
stroke-weight="3">
</shape>
</ng-map>
<div class="panel-body">
<Button class="btn btn-default">Save</Button>
<button class="btn btn-default" ng-click="reset()">Reset</button>
</div>
</div>
$scopeand thecontrollerAssyntax to bind your data. Bad idea.controller('mainCtrl'but in html you useng-controller="srmmobileHoardingCtrl as vm"which points co a different controller.