tri___ton tri___ton - 1 year ago 94
AngularJS Question

include angular controller in index.html

Hi i need to make one page app without additional files like app.js and controller.js

so i do like this and recieve error: Module 'myApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

<meta charset="UTF-8">
<title> JavaScript Angular</title>
<script src="">

var myАpp = angular.module("myАpp", []);

myАpp.controller("firstController", function($scope){
$scope.test = "test-to-test";


<body ng-app = "myApp">
<div ng-controller = "firstController">

So, is it possible to have only one file index.html with angular and controller inside?

Answer Source

You need to have the controller and module inside the <script> tag

<div ng-app="myАpp">
  <div ng-controller="firstController">
<script src=""></script>
var app = 
    angular.module('myАpp', []).controller('firstController', function($scope){
  $scope.test  =  "test-to-test";

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download