why alert is not display in angularjs

天涯浪子 提交于 2019-12-11 13:51:53

问题


I am trying to use require js in angular js project .I am able to show view but issue is that I am not able to get alert on "Login" button click .Actually I show One alert on button click .

Here is my code

http://plnkr.co/edit/jv79297BZLiJpY66rKAc?p=preview

 function ctrl($scope, $state) {

        $scope.login = function () {
          alert("Login is clicked")
        };

    }

I think I got error on console that why I am not able to display alert ?

http://errors.angularjs.org/1.2.12/ng/areq?p0=LoginCtrl&p1=not%20a%20function%2C%20got%20undefined at Error (native)


回答1:


Passing the controller name in the define block of file bootstrap.js did the trick :

    define(['ionic', 'app', 'route', 'LoginCtrl'], function (ionic, app) {
        'use strict';


            angular.element().ready(function () {

                try {
                    console.log(app)
                    angular.bootstrap(document, [app.name]);
                } catch (e) {
                    console.error(e.stack || e.message || e);
                }
            });


    });     

You can find the updated plunker here



来源:https://stackoverflow.com/questions/30991374/why-alert-is-not-display-in-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!