Skip to content

Commit 6b2bc97

Browse files
committed
Translate Module Pattern
1 parent abb6be8 commit 6b2bc97

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

README-ja-jp.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ _このドキュメントは[AngularJS in Patterns](https://github.com/mgechev/a
3434
* [コマンド](#コマンド)
3535
* [コントローラ](#コントローラ-1)
3636
* [ページ・コントローラ](#ページ・コントローラ)
37-
* [Others](#others)
38-
* [Module Pattern](#module-pattern)
37+
* [その他](#その他)
38+
* [モジュール・パターン](#モジュール・パターン)
3939
* [Data Mapper](#data-mapper)
4040
* [References](#references)
4141

@@ -956,13 +956,13 @@ function ChildCtrl($scope, User) {
956956
957957
`ChildCtrl``"Click"` ラベルのあるボタンをクリックするアクションを扱い、また、モデルをスコープに取り付けビューに露出させる責任があります。
958958
959-
### Others
959+
### その他
960960
961-
#### Module Pattern
961+
#### モジュール・パターン
962962
963-
This is actually not a design pattern from Gang of Four, neither one from P of EAA. This is a traditional JavaScript pattern, which main goal is to provide encapsulation and privacy.
963+
これは実際にはGang of FourやP of EAAのデザイン・パターンではありません。これはカプセル化とプライバシーを目的とした伝統的なJavaScriptのパターンです。
964964
965-
Using the module pattern you can achieve privacy based on the JavaScript's functional lexical scope. Each module may have zero or more private members, which are hidden in the local scope of a function. This function returns an object, which exports the public API of the given module:
965+
モジュール・パターンを利用することで、JavaScriptの関数スコープにおけるプライバシーを達成することができます。それぞれのモジュールは関数のローカルスコープの中に隠されたゼロかプリミティブな番号を持っています。この関数は与えられたモジュールのパブリックAPIを出力するオブジェクトを返します。
966966
967967
```javascript
968968
var Page = (function () {
@@ -985,23 +985,23 @@ var Page = (function () {
985985
}());
986986
```
987987
988-
In the example above we have IIFE (Immediately-Invoked Function Expression), which after being called returns an object, with two methods (`setTitle` and `getTitle`). The returned object is being assigned to the `Page` variable.
988+
上記の例は2つのメソッド( `setTitle` `getTitle` )を持ったオブジェクトを返すIIFE(Immediately-Invoked Function Expression)を持っています。返却されたオブジェクトは、 `Page` 変数に関連付けられています。
989989
990-
In this case the user of the `Page` object doesn't has direct access to the `title` variable, which is defined inside the local scope of the IIFE.
990+
このケースでは `Page` オブジェクトのユーザは `title` に直接アクセスするすべを持っていません。 `title` はIIFEのローカルスコープの中に定義されているからです。
991991
992-
The module pattern is very useful when defining services in AngularJS. Using this pattern we can simulate (and actually achieve) privacy:
992+
モジュール・パターンはAngularJSでサービスを定義する際にとても有益です。このパターンを使うことで、プライバシーをシミュレート(事実上達成)することができます:
993993
994994
```javascript
995995
app.factory('foo', function () {
996996

997997
function privateMember() {
998-
//body...
998+
//内容...
999999
}
10001000

10011001
function publicMember() {
1002-
//body...
1002+
//内容...
10031003
privateMember();
1004-
//body
1004+
//内容
10051005
}
10061006

10071007
return {
@@ -1010,6 +1010,8 @@ app.factory('foo', function () {
10101010
});
10111011
```
10121012
1013+
`foo` を別のコンポーネントに注入すると、パブリック・メソッドだけにアクセスしてプライベートメソッドを呼ぶ必要がありません。この方法は再利用可能なライブラリを作成する際にとても強力なたすけになります。
1014+
10131015
Once we want to inject `foo` inside any other component we won't be able to use the private methods, but only the public ones. This solution is extremely powerful especially when one is building a reusable library.
10141016
10151017
### Data Mapper

0 commit comments

Comments
 (0)