添加第二个角度模块

时间:2015-06-02 19:17:52

标签: javascript angularjs module ecmascript-6

我无法将标头组件注册为模块

我卡住了,试图添加new module。我正在使用gulp-angular-scaffold。运行单元测试(Jasmine)时,未定义'header'模块。

好像我错过了一个模块声明,但我不知道在哪里或为什么?

提前致谢

文件夹结构快照:

├──  app/
│   │   ├──  components/
│   │   │   └──  header/
│   │   │   │   ├──  header.controller.js
|   |   |   |   ├──  header.directive.js
|   |   |   |   ├──  header.spec.js
|   |   |   |   ├──  header.js
|   |   |   |   ├──  header.less
│   │   │   │   └──  header.html
│   │   ├──  main/
│   │   │   ├──  main.controller.js
│   │   │   ├──  main.controller.spec.js
│   │   │   └──  main.html
│   │   └──  index.js

index.js :(加载基础/唯一成功的模块)

angular.module('styleguide', ['ngSanitize', 'ui.router', 'ui.bootstrap'])
    .controller('MainCtrl', MainCtrl)

header.js:

'use strict';

import HeaderCtrl from 'header.controller.js';

import HeaderNav from 'header.directive.js';

angular.module('header', ['styleguide'])
    .controller('HeaderCtrl', HeaderCtrl)
    .directive('HeaderDir', HeaderNav)
    .config();

header.controller.js

'use strict';

class HeaderCtrl {
  constructor ($scope) {
    $scope.Project = 'header.controller';
  }
}

HeaderCtrl.$inject = ['$scope'];

export default HeaderCtrl;

header.directive.js

'use strict';

class HeaderNav {

  constructor(){
      return {
        templateUrl: '../components/header/header.html'
      };
  }

}

export default HeaderNav;

1 个答案:

答案 0 :(得分:1)

您需要在索引文件中添加模块 - index.js:

final static String TAG = "HDR_TAG";

static int m_idenValue = 1; // 사진의 이름 중복을 방지하기위한 변수

byte[] pic_data_1;
byte[] pic_data_2;
byte[] pic_data_3;

final int CAPTURE_FIRST =       1;
final int CAPTURE_SECOND =      2;
final int CAPTURE_THIRD =       3;

int takePicFlag = CAPTURE_FIRST;

private PictureCallback mPicture = new PictureCallback() {
    String TAG = "HDR_TAG";

    @Override
    public void onPictureTaken(final byte[] data, Camera camera) {
        // TODO Auto-generated method stub
        File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE);
        if (pictureFile == null) {
            Log.d(TAG,
                    "Error creating media file, check storage permissions");
            return;
        }

        try {
            FileOutputStream fos = new FileOutputStream(pictureFile);
            fos.write(data);
            fos.close();
        } catch (FileNotFoundException e) {
            Log.d(TAG, "File not found: " + e.getMessage());
        } catch (IOException e) {
            Log.d(TAG, "Error accessing file: " + e.getMessage());
        } finally {
            mCamera.startPreview();
            if (takePicFlag == CAPTURE_FIRST)
            {
                pic_data_1 = data.clone();
                Log.d(TAG, "onPictureTaken, data : " + data + "\ntakePicFalg : " + takePicFlag);
                takePicFlag = CAPTURE_SECOND;
            }
            else if(takePicFlag == CAPTURE_SECOND)
            {
                pic_data_2 = data.clone();
                Log.d(TAG, "onPictureTaken, data : " + data + "\ntakePicFalg : " + takePicFlag);
                takePicFlag = CAPTURE_THIRD;
            }
            else
            {
                pic_data_3 = data.clone();
                Log.d(TAG, "onPictureTaken, data : " + data + "\ntakePicFalg : " + takePicFlag);
                takePicFlag = CAPTURE_FIRST;
            }
        }

    }
};

PS:......除非那不是你想要的?