# ng-options

1.注意不要忘記加s，我沒注意到找了好幾分鐘 ...

2\.

根據第一個參考資料內提供的範例，修改成我認為比較容易了解的例子

```
<select ng-model="Select1" ng-options="object.property for object in array">
    <option value="">-- 請選擇 --</option>
</select>

<p>{{ Select1.object.property}}</p>
```

A:陣列 B:物件，也就是陣列內的元素 C:物件的屬性 (想要放哪一個給使用者選，就丟這裡)

```
ng-option="B.C for B in A"
```

題外話:

我原本第一反應是想用 ng-repeat 去做，半夜做到腦袋ㄎ一ㄤ掉，胡搞瞎搞

```
<select ng-repeat="B in A">
    <option>{{B.C}}</option>
</select>
```

做不出來，會變成一大堆的下拉式選單並排在那，後來才查到原來有 ng-option，後來嘗試了第一個參考資料，但是做不出來，一開始還因為沒加s卡很久，後來加了因為觀念不清楚也在那邊亂對應，嚐試排列組合 Q口Q

後來決定多查一點，看保哥的文章，看一看突然有靈感，就做出來了，覺得自己有夠蠢 ...

希望這樣子的舉例可以幫到人囉 \~

參考資料:

Day9- 入門AngularJS筆記-AngularJS指令(8): select的ng-options(<https://ithelp.ithome.com.tw/articles/10135776>)

搞懂 AngularJS 預設模組 select 標籤的 ngOptions 參數用法(<https://blog.miniasp.com/post/2013/05/11/AngularJS-ng-module-select-ngOptions-usage-samples.aspx>)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://brianwu.gitbook.io/brian/angular/ng-options.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
