Reputation: 2565
I'm new to ionic and angular.js. I'm trying to call a function sayHello()
which is written in controller. Here's how I wrote.
In html,
<button class="button button-large"><i class="icon ion-android-send" style="color:blue" ng-click="sayHello()"></i></button>
In controllers.js,
.controller('CommentCtrl',function($rootScope, $scope, $state, CommentService){
$scope.sayHello = function(){
alert('hello');
}
})
In app,
.state('app.comment',
{
url:'/comment',
views:{
'menuContent':{
templateUrl:'templates/comment.html',
controller:'CommentCtrl'
}
}
});
I'm stilling finding my mistake spending hours but I'm still facing that issue. Thanks and regards.
Upvotes: 0
Views: 500
Reputation: 6044
Your HTML should look like this:
<button class="button button-large" ng-click="sayHello()"><i class="icon ion-android-send" style="color:blue"></i></button>
The ng-click should be in the button, not the icon.
Upvotes: 4