Angularjs 离子按钮上的ng显示

Angularjs 离子按钮上的ng显示,angularjs,button,ionic-framework,ng-show,Angularjs,Button,Ionic Framework,Ng Show,我想在开始时隐藏按钮,直到我按下另一个按钮使它们出现。。。 我的代码如下: 按钮控制器+javascript: <div ng-controller="PrintTicket"> <button class="button button-dark" id="btn-printTicket" ng-click="isPrinted()">Print Ticket</button><br></div> myI

我想在开始时隐藏按钮,直到我按下另一个按钮使它们出现。。。 我的代码如下:

按钮控制器+javascript:

<div ng-controller="PrintTicket">
              <button class="button button-dark" id="btn-printTicket" ng-click="isPrinted()">Print Ticket</button><br></div>


myIonic.controller('PrintTicket',function($scope){
var init_state = false;
 $scope.isPrinted = init_state;
$scope.PrintTicket = function(){
$scope.isPrinted = !init_state;
return $scope.isPrinted;
} });

打印票据
myIonic.controller('PrintTicket',函数($scope){ var init_state=false; $scope.isPrinted=初始状态; $scope.PrintTicket=函数(){ $scope.isPrinted=!init_state; 返回$scope.isPrinted; } });
单击后要显示的按钮:

<div ng-controller="PrintTicket" ng-show="isPrinted">
                <button class="button button-dark" id="ticket1_dark"><b>1234</b></button></div>

1234
请你给我一些建议好吗。谢谢你抽出时间


要打印票据,您应该调用
PrintTicket
功能,而不是
isPrinted
,后者将设置
isSelected
标志

ng-click="PrintTicket()"
您不应该定义两次将再次实例化控制器函数的
ng controller=“PrintTicket”
。您应该将两个div包装在一个名为
PrintTicket



经过讨论,您似乎想在两个控制器之间共享数据,因此,您可以在两个控制器之间共享数据。因此,您可以在一个控制器中设置服务变量,并从另一个控制器中的服务访问该值。

要打印票证,您应该调用
printtick
函数,而不是
isPrinted
,后者将设置
isSelected
标志

ng-click="PrintTicket()"
 <div ng-controller="PrintTicket">
          <button class="button button-dark" id="btn-printTicket"
  ng-click="isPrinted()">Print Ticket</button><br></div>


 <div ng-controller="PrintTicket" ng-show="showPrintButton">
   <button class="button button-dark" id="ticket1_dark"><b>1234</b></button></div>





myIonic.controller('PrintTicket',function(`enter code here`$scope){
var init_state = false;

$scope.showPrintButton = false;
$scope.isPrinted=function(){    //$scope.isPrinted is a function
$scope.showPrintButton = true;
}
});
您不应该定义两次将再次实例化控制器函数的
ng controller=“PrintTicket”
。您应该将两个div包装在一个名为
PrintTicket


经过讨论,您似乎想在两个控制器之间共享数据,因此,您可以在两个控制器之间共享数据。因此,您可以在一个控制器中设置服务变量,并从另一个控制器中的服务访问该值。


 <div ng-controller="PrintTicket">
          <button class="button button-dark" id="btn-printTicket"
  ng-click="isPrinted()">Print Ticket</button><br></div>


 <div ng-controller="PrintTicket" ng-show="showPrintButton">
   <button class="button button-dark" id="ticket1_dark"><b>1234</b></button></div>





myIonic.controller('PrintTicket',function(`enter code here`$scope){
var init_state = false;

$scope.showPrintButton = false;
$scope.isPrinted=function(){    //$scope.isPrinted is a function
$scope.showPrintButton = true;
}
});
打印票据
1234 myIonic.controller('PrintTicket',函数(`enter code here`$scope){ var init_state=false; $scope.showPrintButton=false; $scope.isPrinted=function(){/$scope.isPrinted是一个函数 $scope.showPrintButton=true; } });

打印票据
1234 myIonic.controller('PrintTicket',函数(`enter code here`$scope){ var init_state=false; $scope.showPrintButton=false; $scope.isPrinted=function(){/$scope.isPrinted是一个函数 $scope.showPrintButton=true; } });
其中没有
isPrinted()
函数定义。其中没有
isPrinted()
函数定义。您好,谢谢您的回答,我已经实现了您的代码,但仍然不起作用。。。第二个按钮是隐藏的,但即使我单击了第一个按钮,它也不会显示。我已经用控制台检查过了,似乎我已经运行了那行代码($scope.showPrintButton=true),但是按钮仍然没有显示-试试这个插件谢谢你的演示。。但这对我来说不起作用,即使我已经通过PrintTicket controllerCheck将它们放在同一个div包装器中检查您是否在index.htmlHi中包含angualrjs和jquery脚本文件以及您的控制器文件,谢谢您的回答,我已经实现了您的代码,但仍然不起作用。。。第二个按钮是隐藏的,但即使我单击了第一个按钮,它也不会显示。我已经用控制台检查过了,似乎我已经运行了那行代码($scope.showPrintButton=true),但是按钮仍然没有显示-试试这个插件谢谢你的演示。。但这对我来说不起作用,即使我已经通过PrintTicket controllerCheck将它们放在同一个div包装器中,检查您是否已将AngualRJ和jquery脚本文件以及控制器文件包含在index.htmlTank you中,以获取您的答案!我已经对它做了更改,,,但它不起作用:(@Sammi你能在plunkr中复制吗?嗨,这是链接,谢谢你的支持time@Sammi检查附件,感谢您的演示。我已经按照您的代码进行了操作,还更改了PrintTicket的函数名,但是“1234”按钮仍然没有显示为您的演示…我检查了控制台,确认“$scope.isPrinted”的值为真,但没有显示…感谢您的回答!我已经对其进行了更改,,,但它不起作用:(@Sammi你能在plunkr中复制吗?嗨,这是链接,谢谢你的支持time@Sammi检查附件谢谢您的演示。我已经按照您的代码进行了操作,还更改了PrintTicket的函数名,但是“1234”按钮仍然没有显示为您的演示…并且我已经检查了控制台,“$scope.isPrinted”的值是真的,但它没有显示。。。。