angularjs - angular button function run when the page loads -


i have ng-click button page loads execute save(); load page before click on submit button, add empty data database, why not wait clicked? can fix it?

<div class="col-md-2">    <button ng-click="save()">submit</button> </div> 

this part of controller :

var app = angular.module("app", ['angularjs-dropdown-multiselect']); app.controller('autocompletectrl', ['$scope', '$rootscope', 'myservices', function ($scope, $rootscope, myservices) {      $scope.save = function () {         var vcisel = angular.copy($scope.searchtext);         var rolessel = angular.copy($scope.selecteditems);         myservices.addrole(sel, "adad",rolessel)         .success(function (data) {         })         .error(function (error) {             $scope.status = 'unable load customer data: ' + error.message;         });     };     $scope.save(); }]); 

at end of controller definition, invoking save function doing $scope.save();


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -