Error on button click in Ionic framework

angularjs, ionic-framework

Solution

please change your code

angular.module('todo', ['ionic'])
.controller('TodoCtrl', function($scope) {
    {
        // Use our scope for the scope of the modal to keep it simple
        scope: $scope
    }
});

$scope.showAlert = function() {
    alert("show");
};

to

angular.module('todo', ['ionic'])
.controller('TodoCtrl', function($scope) {
    {
        // Use our scope for the scope of the modal to keep it simple
            $scope.showAlert = function() {
                  alert("show");
             };
    }
});

Problem

I am trying to learn Ionic Framework. It might be a very simple question for the one who knows this framework. But I am not able to make this work. What I need to do is just show alert on button click. My index.html code contains button as: ``` <div class="bar bar-footer"> <div class="title"> <button class="button button-light" ng-click="showAlert()"> Origin </button> </div> </div> ``` This is my js code: ``` angular.module('todo', ['ionic']) .controller('TodoCtrl', function($scope) { { // Use our scope for the scope of the modal to keep it simple scope: $scope } }); $scope.showAlert = function() { alert("show"); }; ``` I am getting this error on button click: ``` Uncaught ReferenceError: $scope is not defined app.js:9 (anonymous function) ``` Any idea what I am doing wrong?

Original source