0
I was studying angular and wanted to pull the information out of the main page, but I’m not able to pull the javascript from the outside.
repeat page.html:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body>
<div class="container" ng-app="myApp" ng-controller="customersCtrl">
<div class="row">
<div class="table-responsive">
<table class="table table-hover">
<tbody id="myTable">
<tr ng-repeat="x in names | filter:test">
<td>{{ x }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("teste.js")
.then(function (response) {$scope.names = response.data.records;});
});
</script>
</body>
</html>
test.js ( is to pull this information and play on the main page ) :
angular.module('myApp', []).controller('namesCtrl', function($scope) {
$scope.names = [
'Jani',
'Carl',
'Margareth',
'Hege',
'Joe',
'Gustav',
'Birgit',
'Mary',
'Kai'
];
});
You want to simulate an http request or simply take the variable from the other controller?
– Jackson
I would like to take all the data that is in the test.js and show in the replay.html Because later I will need to take the variables of a database and the $http.get("test.js") will be pointed to the database, only that first I am studying how to do this by a simpler requisition to then go further
– Thiago Luiz Ferreira Tavares
You then want to simulate an HTTP call so that in the future it replaces for a bank call. See below if the answer helps you.
– Jackson