Angular JS with Require JS

时间:2016-04-09 07:03:21

标签: angularjs angularjs-scope requirejs

我正在使用带有Angular Js的requireJs,在我的require-config文件中,我按如下方式引导应用程序:

需要([     “角度”,     “应用”     ],function(angular,app){

     //   alert('sd');
    var $html = angular.element(document.getElementsByTagName('html')[0]);
    angular.element().ready(function() {
        // bootstrap the app manually
        angular.bootstrap(document, ['iStickers']);
                     alert('test');
    });
}

当我尝试使用该函数更改应用程序中的语言时,

 'use strict';
define([
    'angular',
    'angularRoute',
       // 'resource'
], function(angular) {
    alert('ww');
    var loginModule = angular.module('iStickers.login',['ngRoute','ngResource'])

        loginModule.service('translationService',[ function($resource) {
alert('3');
      this.getTranslation = function($scope, language) {
        var languageFilePath = 'translation_' + language + '.json';
        console.log(languageFilePath);
        $resource(languageFilePath).get(function(data) {
          $scope.translation = data;
        });
      };
    }]);



    loginModule.config(['$routeProvider', function($routeProvider) {
        $routeProvider.when('/login', {
            templateUrl: 'views/login/login.html',
            controller: 'loginCtrl'
        });
    }])
    loginModule.controller('loginCtrl', 'translationService', ['$scope', function($scope, translationService) {

   $scope.selectedLanguage = 'no';
   $scope.translate();
    }]);

它给了我一个错误:

  

错误:[ng:areq]参数'loginCtrl'不是函数,得到字符串   http://errors.angularjs.org/1.3.8/ng/areq?p0=loginCtrl&p1=not%20a%20function%2C%20got%20string   minErr /< @ https://code.angularjs.org/1.3.8/angular.js:63:12

0 个答案:

没有答案