1

I have newly started learning AngularJS. When I am running the application it is not showing the data to the view.

Here is my html page. index.html:

<!DOCTYPE html>
<html ng-app="tutorialApp">
<head>
    <meta charset="utf-8">
    <title>Angular Tutorial</title>
    <script src="lib/angular.min.js"></script>
    <script src="js/app.js"></script>
    <script src="js/controllers/tutorialCtrl.js"></script>
</head>
<body ng-controller="TutorialCtrl">
        <h1>{{tutorialObject.title}}</h1>
        <h2>{{tutorialObject.subTitle}}</h2>
        <hr/>Number: {{2+2}}
        <p>{{tutorialObject.bindOutput}}</p>    
</body>
</html>

app.js:

var app = angular.module('tutorialApp', ['tutorialCtrlModule']);

tutorialCtrl.js:

angular.module('tutorialCtrlModule', [])

.controller('ToturialCtrl', ['$scope', function($scope){
    //Code

    $scope.tutorialObject = {};
    $scope.tutorialObject.title = "Angular Tutorial";
    $scope.tutorialObject.subTitle = "Basic";
    $scope.tutorialObject.bindOutput = 2;

}]);

I could not even understand what could be the wrong thing i have done.

I am attaching the screenshot below:

enter image description here

1 Answer 1

2

You need to change the order of controller as tutorialAppp is dependent on tutorialCtrlModule

 <script src="js/controllers/tutorialCtrl.js"></script>
 <script src="js/app.js"></script>

EDIT:

You have made another typo mistake in the html, controller name as "TutorialCtrl" whereas it should be ToturialCtrl

Here is the working DEMO

Sign up to request clarification or add additional context in comments.

1 Comment

After changing the order also the result is same. There might be some other thing which is being missing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.