I'm doing a simple tutorial and cannot get past a very simple thing.
I want to create an element on page load. I've followed the code exactly. I'm using Google Chrome. What is wrong with the following that will not create the audio element?:
index.html
<!doctype html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script src="js/main.js"></script>
</head>
<body>
<div ng-controller="PlayerController">
<button ng-click="play()" class="button" ng-show="!playing">Play</button>
<button ng-click="stop()" class="button alert" ng-show="playing">Stop</button>
Playing audio: <b>{{ playing }}</b>
</div>
</body>
</html>
main.js (in the referenced location js/main.js)
var app = angular.module('myApp', []);
app.controller('PlayerController', ['$scope', function($scope) {
$scope.playing = false;
$scope.div = document.createElement("div");
$scope.audio = document.createElement('audio');
$scope.audio.src = 'media/sample_mpeg4.mp4';
}]);
This is what the source looks like upon page inspection:
<!doctype html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script src="js/main.js"></script>
</head>
<body>
<div ng-controller="PlayerController">
<button ng-click="play()" class="button" ng-show="!playing">Play</button>
<button ng-click="stop()" class="button alert" ng-show="playing">Stop</button>
Playing audio: <b>{{ playing }}</b>
</div>
</body>
</html>
As you can see the audio element is not created. I tried this with even simpler examples where I tried to just add a div.
Thanks