I exported data from MySql db to Json object.
What I want to achieve is actually to see the front end data manipulations by angular.
I think that the problem is in my controller. I placed the Json object inline in ng-init
and it works great.
I tried to lean on this question but with not much success
This is my HTML file
<html ng-app="myApp">
<head>
<title></title>
</head>
<body>
<div style="direction: ltr">
</div>
<h1>תוצאות שאלון</h1>
<div class="table-responsive" ng-controller="ContentCtrl">
<!--ng-controller="ContentCtrl"-->
<table class="table" id="results">
<thead>
<tr>
<th>id</th>
<th>q 1</th>
<th>q 2</th>
<th>q 3</th>
<th>textarea</th>
<th>phone</th>
<th>name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="answer in answers">
<td>{{answer.id}}</td>
<td>{{answer.q1}}</td>
<td>{{answer.q2}}</td>
<td>{{answer.q3}}</td>
<td>{{answer.textarea}}</td>
<td>{{answer.phone}}</td>
<td>{{answer.name}}</td>
</tr>
</tbody>
</table>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script type="text/javascript" src="js/js.js"></script>
<script src="js/controllers.js"></script>
</body>
</html>
this is the controller.js file
var myApp = angular.module('myApp', []);
myApp.controller('ContentCtrl', ['$scope', '$http', function ($scope, $http) {
$http.get('json.php')
.success(function(data) {
$scope.answers = data;
});
}]);
This is my the json i get at the json.php
file, controller.js
and json.php
are in the same folder
[{"id":"6","time":"1453381291","answers":"x","q1":"2","q2":"3","q3":"1","textarea":"test","phone":"954472","name":"Jane"},{"id":"5","time":"1453364067","answers":"x","q1":"1","q2":"2","q3":"3","textarea":"test 1","phone":"954472","name":"John"},{"id":"4","time":"1453363983","answers":"x","q1":"4","q2":"3","q3":"2","textarea":"test 2","phone":"954472","name":"David"}]
Now, I do not get any related error at the consule but I do not see data either.
any help would be great.