2015-01-10 2 views
0

와 같은 형태로 많은 버튼을 AngularJS와. 정보 추가 버튼 제출은 http 게시로 일부 정보를 보냅니다. 취소 정보는 location.path을 다른 페이지로 보냅니다.내가 두 개의 작은 질문이 다른 작업

내가 클릭 할 때 "정보 취소"버튼이 작동하지 않는 것으로 나타났습니다.

두 번째 문제 : 동일한 양식을 사용하여 정보 추가를 클릭하면 메시지와 함께 div 성공을 표시합니다. 그 사업부가 표시되면, 추가 정보 버튼이 사라가

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"); 
     }; 
    } 
}); 

때문에, 누구든지 나를 도울 수 (작동하지 않습니다), 소원? :)

+1

dev 콘솔에 오류 메시지가 표시됩니까? – scniro

+1

두 번째 버튼에 type = "button"추가 = 기본적으로 버튼 유형이 제출됩니다. –

+0

취소 아이콘을 클릭 해 보셨습니까? (icon-hand-right)'ng-click '은'button'에없는'i'에 있습니다. –

답변

0

단추 대신 앵커 태그를 사용하십시오.

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

그리고 앵커 태그에 ng-click을 대신 사용하십시오.

관련 문제