i can get the input and fetch the json i can also insert the data to the $scope.movies
but i can't see the results. what am i missing?
thanks.
the html:
<!DOCTYPE html>
<head>
<title>Learning AngularJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>
<script src="mainController.js" type="text/javascript"></script>
</head>
<body>
<div id='content' ng-app='MyTutorialApp' ng-controller='MainController'>
<input type='text' ng-model='searchMovies' />
<button ng-click='addNew()'>Add</button>
<ul>
<li ng-repeat="movie in movies">1</li>
</ul>
</div>
</body>
</html>
the app:
var app = angular.module('MyTutorialApp',[])
the controller:
app.controller("MainController", function($scope){
$scope.movies = null;
$scope.searchMovies = null;
$scope.addNew = function() {
if ($scope.searchMovies != null && $scope.searchMovies != "") {
fetch('http://www.omdbapi.com/?s=' + $scope.searchMovies)
.then(data => data.json())
.then(data => {
console.log(data)
$scope.movies = data.Search
console.log($scope.movies)});
}
}
});
edit: i'm using live-server to to run this code. maybe it's connected?