angularjs - how do i display base 64 encoded string as image in ionic app in offline -


my code in here here $scope.student_photo variable encoded string first in ajax , stored in local db

$http.post(mdata.url+'getstudentdetails/',{student_id : student_id} ).success(function(data){                 //$scope.student_pic = data.student_details[0].student_pic;                 //$scope.student_photo = data.student_details[0].student_photo;             $scope.myimage=data.student_details[0].student_photo;             //alert($scope.myimage);             // var image_stu = data.student_details[0].student_photo;              // localstorage.setitem("imagedata", image_stu);              // document.getelementbyid("img_stu").src='data:image/png;base64,' + image_stu;     //alert("done");                 var events = data.student_details                      var l = events.length;                     //alert(l);                      db.transaction(function(tx) {                     tx.executesql('select * dashboard ', [], function(tx, results){                              if (results.rows.length == 0)                              {                                 tx.executesql("insert dashboard(dashboard_id, stu_name,clas,sec,student_image) values(?,?,?,?,?)", [ student_id,data.student_details[0].student_name, data.student_details[0].class_name, data.student_details[0].section_name,data.student_details[0].student_photo], function(tx, res) {                                     $scope.dashboarddetails();                                 //alert('inserted');                                 }, function(e) {                                     //alert('error: ' + e.message);                                 });                                }                           });                      });             });              $scope.showscreen = function(screen) {                 $state.go('app.'+screen);             }             $scope.printdashboard = function()              {                 //alert('ss');                 db.transaction(function (tx) {                     // tx.executesql('select * dashboard', [], function (tx, dtresult) {                         //alert("dtresult.rows.length" + dtresult.rows.length);                         // console.log("dtresult.rows.length" + dtresult.rows.length);                         // $scope.totalrecords = dtresult.rows.length;                     // });                     tx.executesql('select * dashboard', [], function (tx, dresult) {                          console.log("dresult.rows.length" + dresult.rows.length);                          dataset = dresult.rows;                     console.log(dresult.rows);                         (var = 0, item = null; <  dresult.rows.length; i++) {                         item = dataset.item(i);                              $scope.dashboarditems.push({stu_name: item['stu_name'],stu_class: item['clas'],stu_sec: item['sec'],stu_img: item['student_image']});                             //$scope.items.push({id: item['notice_title'], notice:item['notice'], event_date: item['event_date']});                             console.log($scope.dashboarditems[0]);                         }                     $state.go('app.dashboard');                        });                 });              }                $scope.dashboarddetails = function()             {                 var citems = [];                 syncwithserver(function(syncsuccess){                     $scope.printdashboard();                 }, false);             } 

question:

how display base64 string image formate.

if base64 string present inside $scope.student_photo

try following img tag display image in view

 <img ng-src="{{'data:image/png;base64,'+student_photo}}"> 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -