rory-h
rory-h

Reputation: 680

ng-init value is not showing

I'm trying to learn the basics on angular. I installed angular via npm.

Just trying to run my first app

        <!DOCTYPE html>
        <html>
        <head>
            <title>ngClassifieds</title>
        </head>
        <body ng-app="ngClassifieds" ng-init="message = 'Hello' ">

        <h1>{{message}}</h1>

        <script type="text/javascript" scr="node_modules/angular/angular.js"></script>
        <script type="text/javascript" scr="scripts/app.js"></script>

        </body>
        </html>

In my app.js it's just this line of code:

 angular.module("ngClassifieds", []); 

I ran the below command to start up the server as I had installed http server on my project directory

 http-server

I opened up my localhost url which was localhost:8080 but for some reasons it was not showing Hello message but instead it was showing {{message}}

Not sure what I went wrong here.

Upvotes: 0

Views: 174

Answers (2)

Ankit Vadi
Ankit Vadi

Reputation: 475

Below code will solve you problem.

angular.module("ngClassifieds", []);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<!DOCTYPE html>
        <html>
        <head>
            <title>ngClassifieds</title>
        </head>
        <body ng-app="ngClassifieds" ng-init="message = 'Hello' ">

        <h1>{{message}}</h1>

        <script type="text/javascript" src="node_modules/angular/angular.js"></script>
        <script type="text/javascript" src="scripts/app.js"></script>

        </body>
        </html>

Upvotes: 1

Ebin Manuval
Ebin Manuval

Reputation: 1255

<script type="text/javascript" scr="node_modules/angular/angular.js"></script>
<script type="text/javascript" scr="scripts/app.js"></script> 

it is not scr chenge it to src

<script type="text/javascript" src="node_modules/angular/angular.js"></script>
<script type="text/javascript" src="scripts/app.js"></script> 

Upvotes: 2

Related Questions