Skip to content

Commit e7bbdca

Browse files
committed
Translate Command
1 parent b504e5a commit e7bbdca

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

README-ja-jp.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ _このドキュメントは[AngularJS in Patterns](https://github.com/mgechev/a
3131
* [スコープ](#スコープ-1)
3232
* [オブザーバ](#オブザーバ)
3333
* [チェーン・オブ・レスポンシビリティ](#チェーン・オブ・レスポンシビリティ)
34-
* [Command](#command)
34+
* [コマンド](#コマンド)
3535
* [Controller](#controller-1)
3636
* [Page Controller](#page-controller)
3737
* [Others](#others)
@@ -841,8 +841,6 @@ JavaScriptコミュニティではこのパターンはパブリッシュ/サ
841841

842842
下の例では `ChildCtrl` がイベントを発し、スコープ・チェーンの上方向に伝播させるところを確認できます。 親のスコープ( `ParentCtrl``MainCtrl` )はコンソールにログを出します: `"foo received"` 。スコープがイベントの終着地点である場合は、イベント・オブジェクトの `stopPropagation` メソッドを呼び出し、コールバックに渡します。
843843

844-
If any of the scopes should be considered as final destination it can call the method `stopPropagation` of the event object, passed to the callback.
845-
846844
```JavaScript
847845
myModule.controller('MainCtrl', function ($scope) {
848846
$scope.$on('foo', function () {
@@ -863,31 +861,31 @@ myModule.controller('ChildCtrl', function ($scope) {
863861

864862
上記UMLダイアグラムの別々のハンドラーはそれぞれコントローラに注入された別々のスコープです。
865863

866-
#### Command
864+
#### コマンド
867865

868-
>In object-oriented programming, the command pattern is a behavioral design pattern in which an object is used to represent and encapsulate all the information needed to call a method at a later time. This information includes the method name, the object that owns the method and values for the method parameters.
866+
>オブジェクト指向プログラミングでは、コマンド・パターンは後々メソッドの呼び出しをする際に必要となる情報をカプセル化した振る舞いのデザイン・パターンです。この情報はメソッド名、メソッドやメソッドパラメータとして利用される値を持つオブジェクトを含みます。
869867
870868
![Command](https://rawgit.com/mgechev/angularjs-in-patterns/master/images/command.svg "Fig. 11")
871869

872-
Before continuing with the application of the command pattern lets describe how AngularJS implements data binding.
870+
コマンド・パターンのアプリケーションに進む前に、AngularJSではどのようにデータ・バインディングをしているか説明しましょう。
873871

874-
When we want to bind our model to the view we use the directives `ng-bind` (for single-way data binding) and `ng-model` (for two-way data binding). For example, if we want each change in the model `foo` to reflect the view we can:
872+
モデルとビューをバインドしたいとき、 `ng-bind` (1方向データ・バインディング)や `ng-model` (双方向データ・バインディング)を使います。例えば、 `foo` モデルの変更をビューに反映させたいとき、このように書くことができます:
875873

876874
```html
877875
<span ng-bind="foo"></span>
878876
```
879877

880-
Now each time we change the value of `foo` the inner text of the span will be changed. We can achieve the same effect with more complex AngularJS expressions, like:
878+
`foo` が変更される度に、spanのテキストは変わります。もう少し複雑なAngularJSの式を書くこともできます:
881879

882880
```html
883881
<span ng-bind="foo + ' ' + bar | uppercase"></span>
884882
```
885883

886-
In the example above the value of the span will be the concatenated uppercased value of `foo` and `bar`. What happens behind the scene?
884+
このケースでは、spanは大文字化した `foo` `bar` の組み合わせとなります。裏では何が起こっているのでしょうか?
887885

888-
Each `$scope` has method called `$watch`. When the AngularJS compiler find the directive `ng-bind` it creates a new watcher of the expression `foo + ' ' + bar | uppercase`, i.e. `$scope.$watch("foo + ' ' + bar | uppercase", function () { /* body */ });`. The callback will be triggered each time the value of the expression change. In the current case the callback will update the value of the span.
886+
`$scope` `$watch` と呼ばれるメソッドを持っています。AngularJSコンパイラが `ng-bind` を見つけると、 `foo + ' ' + bar | uppercase` 式のwatcherを生成します。具体的には、 `$scope.$watch("foo + ' ' + bar | uppercase", function () { /* body */ });` です。式の値が変わる度に、コールバックが呼ばれます。今回のケースではspanを更新します。
889887

890-
Here are the first a couple of lines of the implementation of `$watch`:
888+
これは、 `$watch` の実装の最初の行です:
891889

892890
```javascript
893891
$watch: function(watchExp, listener, objectEquality) {
@@ -904,7 +902,7 @@ $watch: function(watchExp, listener, objectEquality) {
904902
//...
905903
```
906904
907-
We can think of the `watcher` object as a command. The expression of the command is being evaluated on each [`"$digest"`](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest) loop. Once AngularJS detects change in the expression, it invokes the `listener` function. The `watcher` command encapsulates the whole information required for watching given expression and delegates the execution of the command to the `listener` (the actual receiver). We can think of the `$scope` as the command's `Client` and the `$digest` loop as the command's `Invoker`.
905+
`watcher` オブジェクトをコマンドと考えることができます。コマンドの式は、 [`"$digest"`](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest) ループの度に評価されます.AngularJSが式の変更を検知すると、 `listner` 関数を呼びます。 `watcher` コマンドは式の変更に必要な情報をカプセル化しています。そして、コマンドの実行を `listner` (実際のレシーバ)に委譲します。 `$scope` をコマンドの `Client` `$digest` ループをコマンドの `Invoker` と考えることができます。
908906
909907
### Controllers
910908

0 commit comments

Comments
 (0)