Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 需要使用Angular JS绑定单击事件_Angularjs - Fatal编程技术网

Angularjs 需要使用Angular JS绑定单击事件

Angularjs 需要使用Angular JS绑定单击事件,angularjs,Angularjs,我是新来的。我已经写了一个打开模态框的脚本。在模式框中有几个按钮,我想在这些按钮上应用click事件 下面我提到了我的代码: angular.module("vss_shoppingcart_modal",["ui.bootstrap","dialogs","ngSanitize"]).controller("vss_shoppingcart_dialogService",function($scope,$dialogs,$sce){ $scope.init = function(){

我是新来的。我已经写了一个打开模态框的脚本。在模式框中有几个按钮,我想在这些按钮上应用click事件

下面我提到了我的代码:

angular.module("vss_shoppingcart_modal",["ui.bootstrap","dialogs","ngSanitize"]).controller("vss_shoppingcart_dialogService",function($scope,$dialogs,$sce){

  $scope.init = function(){
    dlg = $dialogs.create("/dialogs/whatsyourname.html","vssShoppingCartCTRL",{},{key: false,back: "static"});
  };

}) // end dialogsServiceTest
.controller("vssShoppingCartCTRL",function($scope,$sce,$http,$modalInstance,data){
  $http({
       method: "GET",
       url: "' . $url . '"
   }).
   success(function(data, status, headers, config) {
        $scope.trustedHtml = $sce.trustAsHtml(data); // Apply the html to modal
   });

$scope.cancel = function(){
                $modalInstance.dismiss("canceled");  
            }; // end cancel

  $scope.removeProduct = function(event){
    $http({
           method: "GET",
           url: event.target.id
       }).
       success(function(data, status, headers, config) {

       }).
       error(function(data, status, headers, config) {
            // or server returns response with an error status.
       });
  }; // End removeProduct

  $scope.updateQuantity = function(event){
    $http({
           method: "POST",
           url: "' . $this->getUrl('shoppingcartpopup/index/updateCart') . '",
           data: { "product_id": event.target.id, "qty": "2", "update_cart_action":"update_qty"}
       }).
       success(function(data, status, headers, config) {
           $http({
               method: "GET",
               url: "' . $url . '"
           }).
           success(function(data, status, headers, config) {
               $scope.trustedHtml = $sce.trustAsHtml(data);
           });
       }).
       error(function(data, status, headers, config) {
            // or server returns response with an error status.
       });
  }; // End updateQuantity

}) // end whatsYourNameCtrl
.run(["$templateCache",function($templateCache){
  $templateCache.put("/dialogs/whatsyourname.html","<div class='ngModal' ng-bind-html='trustedHtml'></div>");
}]);// end run / module
在页面加载时,我将一个静态块传递给了模态窗口,然后通过ajax请求,我再次更新了内容

我不知道如何在我的视图文件中应用ng click事件

在视图中,我有一个链接按钮-

<a href="javascript:void(0);" class="dialog-titlebar-close" role="button" ng-bind="cancel()" ng-click="cancel()">
    <span class="header_close_icon">close</span>
</a>

ng click无法处理此链接。

为什么要使用ng bind=cancel?ng bind与Javascript中相同的Angular JS for click事件一起使用。ngBind属性告诉Angular将指定HTML元素的文本内容替换为给定表达式的值,并在该表达式的值更改时更新文本内容。读哦,对不起。你知道如何在我的示例中绑定事件吗?单击=取消是实现你想要的完美方式。为什么它不起作用这是问题所在