0

I have two small questions:

First problem: I have an simple form with two buttons (add information and cancel information). The Add information button submit send some information by http post. The cancel information does a location.path to other page.

It turns out that the "cancel info" button does not work when i click.

Second problem: Using the same form, when i click in Add information it shows a div success with a message. I wish, if that div is displayed, the add information button disappears (does not work )

HTML

<div ng-controller="informationController">
<form name="exampleForm" class="form-vertical col-md-12"  ng-submit="addInformation()">
<div class="row">
 <div class="col-md-4">
   <div class="alert alert-success" ng-show="sucessAdd!=''" role="alert">
    <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
    <span class="sr-only">Success:</span> {{sucessAdd}}
  </div>
</div> 
</div> 

<div class="form-group">                                       
 <div class="col-md-6">
 <div class="col-md-3">
   <button  type="submit" class="btn btn-info" ng-hide="sucessAdd!=''"><i class="icon-hand-right"></i>Add info</button> 
    </div>
  <div class="col-md-3">
    <button   class="btn btn-danger"><i class="icon-hand-right" ng-click="go()" ></i>Cancel info</button> 
     </div>
</div>
</div>
</form>
</div>

CONTROLLER

controller('informationController', function($scope, $location) {
    $scope.sucessAdd="";

    $scope.addInformation = function() { 

        if("information is sent successfully") {
            $scope.sucessAdd='Information created sucessfully!!';
        }

        $scope.go = function() {      
            $location.path("/pathToDefine");
        };
    }
});

so, anyone can help me?? :)

scniro
  • 16,844
  • 8
  • 62
  • 106
user2852514
  • 59
  • 2
  • 10

1 Answers1

0

Use anchor tag instead of button.

<a href="" class="btn btn-danger" ng-click="go()"><i class="icon-hand-right"></i>Cancel info</a>

And use ng-click on anchor tag instead.

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121