angularjs - Reading data from firebase in angularfire -


i have app need store artists , details in database.now want retrieve artists , render of details in front end.how that. secondly, if artist rating in input field using ng-model, how store value in particular artist update details. database structure is:

{     "artists": {         "atif":{             "name":"atif",             "rating":8         },         "himesh":{             "name":"himesh",             "rating":5         }     } } 

and angular.js

(function()   {  var app = angular.module("myapp", ["firebase"]);  app.controller("maincontroller", function($scope, $firebaseobject,$firebasearray) {   var ref = new firebase("https://gigstart.firebaseio.com/");    var artists=ref.child("artists");     // download data local object   $scope.data = $firebaseobject(ref);    // putting console.log here won't work, see below     ref.on("value", function(snapshot)     {       console.log(snapshot.val());     }, function (errorobject)      {       console.log("the read failed: " + errorobject.code);     });      var artistsref=new firebase("https://gigstart.firebaseio.com//artists");     }); //end of controller 

now want render name , rating of each artist in front end.can like

<div ng-repeat="artist in artists">     {{artist.name}}     {{artist.rating}} </div> 

you have list of artists, want ng-repeat on in angular view. can accomplish by:

app.controller("maincontroller", function($scope, $firebasearray) {   var ref = new firebase("https://gigstart.firebaseio.com/");        var artists = ref.child("artists");    $scope.artists = new $firebasearray(artists); } 

please take moment go through angularfire quickstart before starting on own project. covered in step 5.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -