2016-03-28 33 views
-2

Düğme oluşturmak istediğimde bir html sayfası başlattığımda. Nasıl yapabilirim? Herkes içinangularJS kullanarak bir html sayfası nasıl başlatılır

<button ng-model="status" ng-init="status=true" ng-click="status=!status">  
    <span ng-show="status == true" >Activo</span> 
    <span ng-show="status == false">Desactivo</span> 
</button> 

Teşekkür: İşte tam olmayan bir örnektir.

+1

... Yani bir istiyorum link? – Makoto

+2

Öğle yemeğiniz için bir 'a' satın almak isteyebilirsiniz ;-) – Marged

+0

Jajajajaja !!! başlatmak!!!! Jajajaja. –

cevap

0

Bunu çözmek için basit 'a' etiketi kullanabilirsiniz: Burada,

<a href="somepage.html">Lunch somepage.html </a> 

Sen de bu kullanarak angularjs çözebilir bir örnek:

<!DOCTYPE html> 
<html> 
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> 
<body> 

<div ng-app="myApp" ng-controller="myCtrl"> 

<button ng-model="status" ng-init="status=true" ng-click="myFunc()"> 
<span ng-show="status == true" >Activo</span> 
    <span ng-show="status == false">Desactivo</span> 
</button> 


</div> 

<script> 
var app = angular.module('myApp', []); 
app.controller('myCtrl', function($scope, $window) { 
    $scope.myFunc = function(){ 
     $scope.status = !$scope.status; 

     $window.location.href = '/somepage.html'; //this will redirect you to somepage.html 
    } 

}); 
</script> 

</body> 
</html> 
+0

Teşekkür ederim Han Arantes. –

İlgili konular