以下のinitメソッドを持つtypescriptコントローラがあります。私はmessageresult が欲しいすべてのデータを得ることができます。anglejsを使用してデータをドロップダウンにバインドする
init() {
this.accountLocationService.getAccountLocationCollection(this.customerNumber)
.success(messageresult => {
this.acctLocationCollection = messageresult;
//alert(this.acctLocationCollection.accountlocation[0].aliasName);
})
.error(error => {
alert(error);
});
}
acctLocationCollectionは、二つ以上のオブジェクトを持つことができると私は、以下のドロップダウンに aliasNameは、すべての値をバインドする必要があります。 どうすればこの問題を解決できますか?これが私の最初のAngularJsプロジェクトです。
<div id="acctDetail">
<p>Select an Account:</p>
<div class="selectAccount">
<select class="selAccounts" name="DeliverToCustomerNumber" ng-change="" id="DeliverToCustomerNumber"
ng-options="ac for ac in alc.acctLocationCollection.aliasName">
</select>
</div>
<div id="address">
<dl>
<dd class="acctName">{{alc.acctLocationCollection.DeliverToCompanyName}}</dd>
<dd class="acctNo">{{alc.acctLocationCollection.DeliverToCustomerNumber}}</dd>
</dl>
</div>
</div>
は、データはあなたの選択にng-model
を持っていないにconsole.log
object
accountlocation:Array[2]
0:object
aliasName:"1234"
deliverToCustomerNumber: "25235"
1:object
aliasName:"2345"
deliverToCustomerNumber: "23523"
をちょうどノート:次のようにこれを行うには、単にあなたの
ng-options
を構築する必要があります'関数。 TypeScriptコンストラクタを使用するだけで済みます。 (コンストラクタから既に 'init()'を呼び出している場合を除き):) –@BenBeckさらにAngular 1.5.xでは、$ onInit(){}をTypeScriptとともに使用することができます。あなたのコンストラクタからそれを呼び出す。モジュールがインスタンス化されると自動的に起動します。 – Lex