为什么警报不会在控制器中使用角度js发射

时间:2015-06-26 04:31:37

标签: angularjs requirejs

我正在尝试创建一个登录页面。我的登录页面上有一个控制器。点击按钮我正在显示警报。但它没有显示。我创建了一个控制器模块,为什么我不能创建plunker或小提琴。我将分享我编写控制器的小代码。

Here is my code

LoginCtrl.js

Accounts.onCreateUser(function(options, user) {

    ...

    Meteor.setTimeout(function () {
        Roles.addUsersToRoles(user._id, roles, group);
    },0);
    ...
  
});

controller.js

define(function () {
    'use strict';

    function ctrl($scope, $state) {

        $scope.login = function () {
           alert("--")
        };

    }

    ctrl.$inject = ['$scope', '$state'];
    return ctrl;

});

1 个答案:

答案 0 :(得分:0)

Make sure in your HTML file you have added the controller name to the parent element or the appropriate element.You need to give the same controller name in both your HTML file and also the js file. Make sure your controller file is included in your index.html file.