My angular SPA databinding is not updating automatically. Hoping you can tell me why.
-
This is my JS file:
var app = angular.module('SDMApp', ['ngRoute']);
app.config(function ($routeProvider) {
$routeProvider
.when('/para', {
templateUrl: 'view/ParaView.html',
controller: 'MainController'
});
});
app.controller('MainController', function($scope) {
$scope.CurrentlyShowing = "Hello";
});
And my html file:
<!DOCTYPE html>
<html ng-app="SDMApp">
<head lang="en">
<meta charset="UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular-route.min.js"></script>
<script src="Angular.js"></script>
<title></title>
</head>
<body ng-controller="MainController">
<div ng-view></div>
<input ng-model='CurrentlyShowing'>
</body>
</html>
And my template:
<p>{{ CurrentlyShowing }}</p>
-
Although it shows "Hello" like it should initially, when I write in my input element (the html input element in the body), the paragraph from the template doesn't update. Here is a plunker of this scenario: http://plnkr.co/edit/ALEDabL7lmKKgFmGzCce?p=preview .
When I replace the ng-view div with my paragraph from the template, and write in my input element, it updates fine. Here is a plunker of this scenario: http://plnkr.co/edit/TniFrGYBnNQLz8A3BfQ5?p=preview .
Could anyone tell me what is wrong?