当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript AngularFire.object方法代码示例

本文整理汇总了TypeScript中angularfire2.AngularFire.object方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AngularFire.object方法的具体用法?TypeScript AngularFire.object怎么用?TypeScript AngularFire.object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angularfire2.AngularFire的用法示例。


在下文中一共展示了AngularFire.object方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Date

        this.af.auth.login({ email: this.rs.genEmail(phone), password: this.password }).then((authData) => {
            //console.log("Rs2:" + authData.uid);
            this.authData = authData;
            //localStorage.setItem('uid', authData.uid);
            this.rs.uid = authData.uid;
            var usersRef = this.af.object("/users/" + this.authData.uid);
            usersRef.update({
                lastlogin: (new Date()).toISOString()
            });

            usersRef.subscribe(res => {
                let role = res.role;
                this.rs.dealer = res.dealername;
                this.rs.role = res.role;
                this.rs.uid = res.uid;
                this.rs.ownerId = res.ownerid;
                this.rs.phone = res.phone;
                this.rs.fname = res.fname;
                this.rs.lname = res.lname;
                //console.log("role:" + role + " getRole:" + this.rs.role);

            }
            );

        }).catch((error) => {
开发者ID:davidrensh,项目名称:ng2autoService,代码行数:25,代码来源:AdminLogin.ts

示例2:

    af.auth.asObservable().filter(user => user !== null).subscribe(user => { // Skip null values
      this.boardURL = 'users/' + user.uid + '/boards/' + routeParams.get('key');
      this.board = af.object(this.boardURL);
      this.lists = af.list(this.boardURL + '/lists', { query: { orderByChild: 'priority' } });
      this.tasks = af.list(this.boardURL + '/tasks', { query: { orderByChild: 'priority' } });

      this.listObservable = af.list(this.boardURL + '/lists');
      this.taskObservable = af.list(this.boardURL + '/tasks');
    });
开发者ID:Denhai,项目名称:everyday-butter,代码行数:9,代码来源:board.component.ts

示例3: updateWorkout

 updateWorkout(workout: Workout, callback = (workoutKey) => {}) {
   let key = workout["$key"];
   delete workout["$key"];
   const promise = this.af.object("/workouts/" + key).update(workout);
   promise.then(_ => {
     callback(key);
   }).catch(err => {
     console.log(err);
     callback(false);
   });
 }
开发者ID:baseballlover723,项目名称:angularattack2016-hairforce,代码行数:11,代码来源:workout.service.ts

示例4: updateExercise

 updateExercise(exercise: Exercise, callback = (exerciseKey) => {}) {
   let key = exercise["$key"];
   delete exercise["$key"];
   const promise = this.af.object("/exercises/" + key).update(exercise);
   promise.then(_ => {
     callback(key);
   }).catch(err => {
     console.log(err);
     callback(false);
   });
 }
开发者ID:baseballlover723,项目名称:angularattack2016-hairforce,代码行数:11,代码来源:exercise.service.ts

示例5: getAssignment

 getAssignment(id: string, callback = (assignment) => {}) {
   let sub = this.af.object("/assignments/" + id).subscribe((assignment) => {
     sub.unsubscribe();
     if (!assignment) {
       callback(false);
       return;
     }
     assignment.$key = id;
     callback(assignment);
     return;
   });
 }
开发者ID:baseballlover723,项目名称:angularattack2016-hairforce,代码行数:12,代码来源:assignment.service.ts

示例6: getWorkout

 getWorkout(id: string, callback = (workout) => {}) {
   let sub = this.af.object("/workouts/" + id).subscribe((workout) => {
     sub.unsubscribe();
     if (!workout) {
       callback(false);
       return;
     }
     workout.$key = id;
     callback(workout);
     return;
   });
 }
开发者ID:baseballlover723,项目名称:angularattack2016-hairforce,代码行数:12,代码来源:workout.service.ts

示例7: getExercise

 getExercise(id: string, callback = (exercise) => {
 }) {
   let sub = this.af.object("/exercises/" + id).subscribe((exercise) => {
     sub.unsubscribe();
     if (!exercise) {
       callback(false);
       return;
     }
     exercise.$key = id;
     callback(exercise);
     return;
   });
 }
开发者ID:baseballlover723,项目名称:angularattack2016-hairforce,代码行数:13,代码来源:exercise.service.ts

示例8: if

    dragulaService.drop.subscribe(([bag, element, target, source, next]) => {
      // Look at the adjacent tasks in the list and pick a priority in the middle
      let prev = element.previousElementSibling;

      if (bag === 'taskBag') {
        let observables: Observable<Task>[] = [Observable.of(undefined), Observable.of(undefined), Observable.of(undefined)];
        // Get the keys from the DOM. Stored in data-key attributes.
        if (prev != null && prev.className === 'task') observables[0] = (af.object(this.boardURL + '/tasks/' + prev.dataset.key));
        if (element != null && element.className === 'task') observables[1] = (af.object(this.boardURL + '/tasks/' + element.dataset.key));
        if (next != null && next.className === 'task') observables[2] = (af.object(this.boardURL + '/tasks/' + next.dataset.key));

        Observable.zip(...observables) // Combine the observables then subscribe asynchronously
          .take(1) // only subscribe once
          .subscribe(([previousTask, movedTask, nextTask]: Task[]) => {
            let lower = -4; // arbitrary
            let upper = 4;  // arbitrary
            if (previousTask && previousTask.priority != null) {
              lower = previousTask.priority;
            } else if (nextTask && nextTask.priority != null) {
              lower = nextTask.priority - 4;
            }
            if (nextTask && nextTask.priority != null) {
              upper = nextTask.priority;
            } else if (previousTask && previousTask.priority != null) {
              upper = previousTask.priority + 4;
            }
            // Update the priority of the moved task in the database
            movedTask.priority = lower + (Math.abs(upper - lower) / 2);
            // Check if it swapped to a different list
            if (target.dataset.key !== source.dataset.key) {
              movedTask.list = target.dataset.key;
            }
            this.taskObservable.update(element.dataset.key, movedTask);
          });
      } else if (bag === 'listBag') {
        // TODO reorder the lists, similar as above
      }
    });
开发者ID:Denhai,项目名称:everyday-butter,代码行数:38,代码来源:board.component.ts

示例9: updateAssignment

 updateAssignment(assignment: Assignment, callback = (assignmentKey) => {}) {
   let key = assignment["$key"];
   let exercisekey = assignment.exercise['$key'];
   delete assignment["$key"];
   delete assignment.exercise;
   // console.log(assignment);
   const promise = this.af.object("/assignments/" + key).update(assignment);
   promise.then(_ => {
     console.log("GOT", key);
     callback(key);
   }).catch(err => {
     console.log(err);
     callback(false);
   });
 }
开发者ID:baseballlover723,项目名称:angularattack2016-hairforce,代码行数:15,代码来源:assignment.service.ts

示例10: addTask

 addTask(listKey, input) {
   let push = priority => {
     let task: Task = { list: listKey, text: input.value, priority };
     this.taskObservable.push(task);
     input.value = '';
   };
   let lastTask = document.querySelector(`ul[data-key="${listKey}"] li:last-child`);
   if (!lastTask) {
     push(0);
     return;
   }
   this.af.object(this.boardURL + '/tasks/' + lastTask.attributes['data-key'].value)
     // TODO lastTask.dataset.key (can we use this? or is it only available in some browsers?)
     .subscribe((value: Task) => {
       push(value.priority + 2);
     });
 }
开发者ID:Denhai,项目名称:everyday-butter,代码行数:17,代码来源:board.component.ts


注:本文中的angularfire2.AngularFire.object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。