我已经定义了app.js来调用Some-View.view.html和Some-View-controller.js。 Some-View.view.html具有ng-click指令来调用Some-View-controller.js中定义的函数
使用ng-click指令单击元素时,不会调用Some-View-controller.js中定义的函数。
请让我知道如何调用Some-View-controller.js中定义的函数,以及访问链接到ng-model的变量。
app.js
.when('/Some-View', {
controller: 'SomeViewController',
templateUrl: 'Some-View/Some-View.view.html',
controllerAs: 'vm'
})
部分 - 视图 - controller.js
(function () {
'use strict';
angular
.module('app')
.controller('SomeViewController', SomeViewController);
SomeViewController.$inject = ['UserService', '$rootScope'];
function SomeViewController(UserService, $rootScope) {
/*Discussion Board related Functions*/
var vm = this;
/////
vm.comments = [];
vm.currCmtIndx=-1;
vm.userReply="";
function functionToBeCalledFrom_NG_CLICK() {
}
}
/*End - Discussion Board related Functions*/
} /*End - SomeViewController */
})();
HTML代码段
<div class="form-group" >
<div class="col-sm-offset-2 col-sm-10">
<button class="btn btn-success btn-circle text-uppercase" type="button" id="submitComment" ng-click="vm.functionToBeCalledFrom_NG_CLICK()"><span class="glyphicon glyphicon-send" id="qazwsx"></span> Summit comment</button>
</div>
</div>