离子角度app指令不按下按钮点击方法

时间:2014-05-18 09:21:04

标签: javascript angularjs angularjs-directive

在下面的指令中,我尝试添加要调用的方法roll(),但事实并非如此。我想我可能在错误的范围或某事上,尝试将它添加到两个不同的...任何线索?

.controller('RollViewCtrl', function($scope){
      $scope.someTitle='BLA';
      $scope.isRolling = true;
      $scope.roll = function(){
        console.log('roll Called');
      };

      /*jshint multistr: true */
    }).directive('myDice', [ function() {
      return {
        restrict: 'E',
        template: '<div id="wrapper">\
                          <button id="rollButton" class="button button-dark button-full button-positive" ngClick="roll()">\
                          Roll</button>\
                          <input id="secondroll" name="roll" type="checkbox">\
                          <input id="roll" name="roll" type="checkbox">\
                          <label for="roll">Roll it!</label>\
                          <label for="secondroll"><span>Stop!</span></label>\
                          <div id="platform">\
                            <div id="dice">\
                              <div class="side front">\
                                <div class="dot center"></div>\
                              </div>\
                              <div class="side front inner"></div>\
                              <div class="side top">\
                                <div class="dot dtop dleft"></div>\
                                <div class="dot dbottom dright"></div>\
                              </div>\
                            .......
                            </div>\
                          </div>',
        replace: true,
        transclude: true,
        link: function(scope, element, attrs) { scope.roll = function() { alert('hi'); }}
      };
    }]);

0 个答案:

没有答案