angularjs - AngularFire 0.8 bindTo only works for first change -
Hi, I am trying to create an app using the new Analyzer version 0.8, which has an updated version of the $ bind, which is $ bindTo Although IM is getting a little hard with this method, the only way to tie the changes seems to be back in the firebase on the first update. Do not make later changes to the data on the page. Do I need to redeem the object on every update?
I have created a simple app to show this problem. In the app, any object is created in a factory (test) that adds the object to the $ root scope. The administrator then accesses it, and a viewer accesses it and updates as needed.
Factory (services / test.js)
app factory ('test', function ($ firebase, FIREBASE_URL, $ rootScope) { Var URL = FIREBASE_URL + 'test12 /'; var test = {create: function (user, obj) {console.log ("create new test object"); Obj.something = "1234"; obj.somethingElse = "567" ; Obj. $ Priority = "7"; obj. $ Save (set); setCurrentTest (user);}, meet current: function () {Return $ rootScope .currentTest;}}; Function Set Bootstrap (user) {var obj = $ Firebase (new firebase). $ AsObject (); obj. $ Loaded (). Then (function () {if (obj. $ Priority) {Obj. $ BindTo ($ rootScope, 'CurrentTest'). Then (function () {console.log ("bound");});} else {Test.create (user, obj);}});} $ RootScope. $ ('$ FirebaseSimpleLogin: Login ', function (e, user) {setCurrentTest (user);}); return exam;});
Controller (administrator / test.js)
app.controller ('TestCtrl', function ($ scope, test) )) {$ Scope.testy = Test.getCurrent ();});
See (test.html)
& lt; Div class = "t_center" & gt; & Lt; H3 & gt; Trial & lt; / H3 & gt; & Lt; Div & gt; & Lt; Input type = "test" name = "test1" value = "testy.something" ng-model = "testy something." /> & Lt; Input type = "test" name = "test2" ng-model = "testy.somethingElse" /> & Lt; / Div & gt; & Lt; Br / & gt; & Lt; / Div & gt;
is using IM;
- Angular # 1.2.21
- Firebase # 1.0.18
- Firebase - Simple-Login # 1.6.2
Any advice was greatly appreciated.
Background I do not think my example code highlights that I was trying to get very well, so for everything I was trying to do I will provide a little background The object I create here (for example, called "test") is basically a user profile. There are some preferences in the types of common use (name etc.), instead of copying the code that is used by all controllers, I wanted to create that service, which had obtained a user profile on login and it The $ root that was placed in was necessary for some controllers. If a profile is not available in the service system, then it makes it (with the sensible value).