0

I have 3 files: EventDetails.html, app.js, and EventController.js.

Here is the body of the html

<html ng-app="eventsApp">
 <head>...</head>
<body>
<div class="container">
    <div ng-controller="EventController">
    {{event.name}}</div>
</div>
</body>
</html>

app.js:

var eventsApp = angular.module('eventsApp', []);

EventController.js:

eventsApp.controller('EventController',
    function EventController($scope) {
        $scope.event = {
            name: 'Angular',
            date: '2/23/16',
            time: '11:22 am'
        };
    });

when I run it, the view displays "{{event.name}}" and not "Angular". If everything looks like it should work, then I probably have an issue with my links in html to the JS pages.

Here it is in Plunker http://plnkr.co/edit/T7Hexx9GEbp63eDxwCLE?p=preview

7
  • 1
    when you see {{event.name}} it is usually an indicator that there was an error. Have you checked the console to see if there are any? Commented Feb 23, 2016 at 17:39
  • 2
    doesn't look like you set an ng-app="eventsApp" either Commented Feb 23, 2016 at 17:39
  • create a plunker if possible? Commented Feb 23, 2016 at 17:40
  • thanks charlietfl, I just didn't show it here but I did have ng-app in the html tag Commented Feb 23, 2016 at 17:42
  • Basic code shown works fine here Commented Feb 23, 2016 at 17:44

1 Answer 1

1

ive fixed it

on your plunker your script tags in head are very wrong

you need to point to angular and you need to point to your js files

ive changed them to ...

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>

<script src="script.js"></script>
<script src="EventController.js"></script>

and i changed the EventController file too ...

eventsApp.controller('EventController',
    function($scope) {  // NO NEED FOR FUNCTION NAME HERE
        $scope.event = {
            name: 'Angular',
            date: '2/23/16',
            time: '11:22 am'
        };
    });

job done

plunk of fix ... http://plnkr.co/edit/tkPrhZcxzTlLzLg6f65C?p=preview

hopefully u can view that

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

Comments

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.