HTML
<div class="container" ng-controller="main" style="margin-top: 30px;">
<div class="row">
<div class="col-md-12">
<p>{{firstName}}</p>
<br>
<p>{{lastName}}</p>
<br>
<button class="btn btn-primary" ng-click="showLog()">MyButton</button>
</div>
</div>
</div>
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
main.js
angular.module('app').controller('main',
function ($scope, $http, $state, $sce, urls) {
$scope.firstName = 'John';
$scope.lastName = 'Doe';
$scope.showLog = function () {
console.log("angular works");
}
});
I'm fairly new to AngularJS and am just trying to connect Angular File with Html. so far I created the showLog function but pressing it does nothing at all. I feel like ng-controller does nothing and {{firstName}} & {{lastName}} are showing just like that (meaning the 'John' 'Doe' don't get injected)
Also I have another question - If I'm loading the Angular file with <script type="text/javascript" src="js/main.js"></script> , Why do I need to specify ng-controller ? shouldn't this already work?
