javascript - Getting data from database to angular js -
javascript - Getting data from database to angular js -
i'm new angular js , i've been learning codeschool.
i have problem can't figure out how solve: want info php file i'm working on first wanted create short illustration because doesn't create sense me, , can never retreive info has php file angular controller.
i have uploaded on jsfiddle can check out if want
here's html, it's pretty basic:
<div ng-app="app">     <div ng-controller="mycontroller c">          <h1>{{c.title}}</h1>         <p>controller trial: {{c.content}}</p>     </div> </div>    and here javascript source:
var app = angular.module("app", []); app.controller("mycontroller", ['$http', function ($http) {     this.title = "my title";     var filecontent = "data should replaced";     $http.get("http://www.otherwise-studios.com/example.php")         .success(function (data) {             filecontent = data;             //i don't know why   info not loaded here :s         });     this.content = filecontent; }]);    finally, output i'm getting:
my title  controller trial:   info should replaced    if visit link i'm retreiving info should see output "you connected php file", said before, info seems never updated variable:
this.content    thank much help
juan camilo guarin p
data isn't loaded here, because "content" primitive. have 2 ways: init "content" object or write smth this:
var filecontent = "la la la",     = this;  $http.get("http://www.otherwise-studios.com/example.php")     .success(function (data) {         that.content = data;     });        javascript php json angularjs http 
 
Comments
Post a Comment