2016-06-24 10 views
1

私はfirebaseArrayを使用してリピートngのから選択された値を取得したいがprofile.namefirebaseArrayを使用してng-repeatからサブプロパティ値を取得する方法は?

.json

profile: { 
    name: 'default', 
    description: 'default', 
    permissions: { 
    regUser: false, 
    regProfile: false, 
    regCustomer: false 
    } 
} 

.htmlを

<select class="form-control"> 
       <option ng-repeat="profile in vm.profiles" ng-model="vm.firebaseUser.profile">{{profile.name}}</option> 
      </select> 

の.js

の値を取得し、ロードされました
vm.createApplicationUser = function() { 
      var profilesRef = firebase.database().ref('application/profiles/name/'); 
      vm.profiles = $firebaseArray(profilesRef); 
      var usersRef = firebase.database().ref('application/users/').push().set({ 
       displayName: vm.firebaseUser.displayName, 
       email: vm.firebaseUser.email, 
       role: vm.firebaseUser.role, 
       profile: vm.firebaseUser.profile 
      }); 
     }; 

エラー

Error: Firebase.set failed: First argument contains undefined in property 'application.users.-KL3BQ-F5a-HLa32an-R.profile' 
    at Error (native) 
    at Bf (http://localhost:3000/bower_components/firebase/firebase.js:340:67) 
    at http://localhost:3000/bower_components/firebase/firebase.js:341:166 
    at Cb (http://localhost:3000/bower_components/firebase/firebase.js:259:627) 
    at Bf (http://localhost:3000/bower_components/firebase/firebase.js:340:424) 
    at Af (http://localhost:3000/bower_components/firebase/firebase.js:339:682) 
    at U.g.set (http://localhost:3000/bower_components/firebase/firebase.js:467:241) 
    at AdminCtrl.vm.createApplicationUser (http://localhost:3000/src/client/app/admin/admin.js:28:81) 
    at fn (eval at <anonymous> (http://localhost:3000/bower_components/angular/angular.js:14605:15), <anonymous>:4:271) 
    at expensiveCheckFn (http://localhost:3000/bower_components/angular/angular.js:15694:18) 
+0

あなたがしたいものを手に入れませんでした。あなたの問題は何ですか?選択メニューに値を表示したいだけですか?なぜあなたはこのプッシュを呼び出していますか?セレクトするのと同じ方法でセットされていますか? – adolfosrs

+0

'select' html要素で選択された値は、firebaseセット関数(profile:vm.firebaseUser.profile)のフィールドの値です。私はこのプロパティにhtml({{profile.name}})で表示するようなプロファイルの名前だけを保存したいと思います。プッシュ関数は、データベース内の新しいエントリのランダムキーを生成します。 – gcfabri

答えて

0

ng-modelは<select>タグであり、<option>ではありません。

関連する問題