0

古い技術スタック、うまくいけば誰かが手を貸してくれます。mathjs ライブラリを $scope にラップしようとしていますが、問題があります。

私のルート(angular-ui-router、angularjs):

  .state('statistics', {
  url: '/statistics/{jobTitle}',
  views: {
    'content': {
      template: '<statistics></statistics>',
      controller: function($scope, mathController, simpleObj){
                    console.log(simpleObj);
                    console.log(mathController);

        $scope.$on('ocLazyLoad.fileLoaded', function(e, module) {
          console.log('module loaded', module);
          console.log(mathController);
        });
        $scope.mathController = mathController;
        $scope.simpleObj = simpleObj;
      }
    },
    'footer': {
      template: '<footer></footer>'
    },
  },
  resolve: { // Any property in resolve should return a promise and is executed before the view is loaded
    mathController: ['$ocLazyLoad', function($ocLazyLoad) {
      // you can lazy load files for an existing module
             return $ocLazyLoad.load('/assets/js/math.min.js')
    }],
    simpleObj:  function(){
       return {value: 'simple!'};
    },
  }

これで、console.log(mathController) は undefined をログに記録し、simpleObj は undefined を返します。誰でもこれを説明できますか?どうすれば修正できますか?イベントが発生した後にコンソールにログを記録しても、まだ未定義であるため、非同期にロードされることは問題ではありません。私の仮定は、コンソールで関数を見ることができるはずですか?

4

0 に答える 0