AngularJS ng-click can't call function from ctrl

时间:2017-04-06 17:10:36

标签: html angularjs

I made a route in my app, and I want to show alert when click button in template :

please help me:

this is my JavaScript:

var trainingApp = angular.module('training', ['daypilot','ngRoute']);

angular.module('training')



.config(function($routeProvider){
    $routeProvider
    .when('/',{
        templateUrl: 'index.html',
        controller: 'mainCtrl'
    })
    .when('/login',{
        templateUrl: 'login.html',
        controller:  'profilecontroller'
    })
})


.controller('profilecontroller',['$scope', function($scope){
$scope.alertt = function(){

    alert("okkkkkkk");
}
}])

.controller('mainCtrl', .........
<button  ng-click="alertt()">ok</button>

0 个答案:

没有答案