HAKASHUN / manabi

manabi
14 stars 1 forks source link

AngularJS個人的ルールまとめ #67

Open HAKASHUN opened 9 years ago

HAKASHUN commented 9 years ago

IIFE(Immediately-invoked function expression)を使う

(function(angular){
  'use strict';
  // 処理...
})(angular)
HAKASHUN commented 9 years ago

1ファイル1モジュール

Bad

// sample/app.js
angular.module('sample', []);
...

angular.module('sample.controllers', []);
...

Good

// sample/app.js
angular.module('sample', []);
...
// sample/controller.js
angular.module('sample.controllers', []);
...
HAKASHUN commented 9 years ago

モジュール

モジュールの種類

HAKASHUN commented 9 years ago

コントローラ

HAKASHUN commented 9 years ago

ディレクティブ

HAKASHUN commented 9 years ago

フィルタ

HAKASHUN commented 9 years ago

サービス

HAKASHUN commented 9 years ago

ファイル名・ディレクトリ名の命名規則

// BAD
hogeDialog.js
fooBar/
fugaHoge.html
// GOOD
hoge-dialog.js
foo-bar/
fuga-hoge.html