Hello,
feel a bit stupid here... for the past few hours I am trying to get a view
to display all contacts where before they did show up allright. Now nothing
shows up
It's an app with several views. The router makes sure a controller is
activated with the current view. When starting the app the url changes to
the default view: 127.0.0.1:9000/#/contacts. With that view comes a
controller, it gets the data injected from a service and everything should
be displayed in the view using a ng-repeat directive.
Problem is, the view with the contacts data is never shown, not even the
header is displayed. If I look in FireBug, the <div ng-view></div> in
index.htm (which is supposed to display the templates specified in the
router) stays empty....I did import the Angular-router.js
So here is my index.cfm (all of it) skeleton generated by Yeoman:
<!DOCTYPE html>
<html ng-app="iShareApp">
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><html class="no-js"> <![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>iShare uitleenbeheer</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory
-->
<!-- build:css styles/vendor.css -->
<!-- bower:css -->
<link rel="stylesheet"
href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->
<!-- endbuild -->
<!-- build:css({.tmp,app}) styles/main.css -->
<link rel="stylesheet" href="styles/main.css"/>
<link rel="stylesheet" href="styles/lenenStyles.css"/>
<!-- endbuild -->
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong>
browser. Please <a href="http://browsehappy.com/">upgrade your browser</a>
to improve your experience.</p>
<![endif]-->
<!-- Add your site or application content here -->
<div class="container-fluid">
<div class="jumbotron"><h1>iShare beheer</h1></div>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<li><a ng-href="#/contacts"
ng-class="{'selected' : isSelected('/contacts')}">Contacten</a></li>
<li><a ng-href="#/items" ng-class="{'selected'
: isSelected('/items')}">Uitgeleend</a></li>
</ul>
</div>
<waiting>Just a moment...</waiting>
</div>
<div ng-view class="container"></div>
</div>
</div>
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new
Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-X');
ga('send', 'pageview');
</script> -->
<!--[if lt IE 9]>
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/json3/lib/json3.min.js"></script>
<![endif]-->
<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<!--<script src="bower_components/jquery/jquery.js"></script>-->
<script
src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.js"></script>
<script src="http://code.angularjs.org/1.2.11/angular.js"></script>
<script
src="http://code.angularjs.org/1.2.11/angular-animate.js"></script>
<script
src="http://code.angularjs.org/1.2.11/angular-route.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script
src="bower_components/angular-cookies/angular-cookies.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/services/contactService.js"></script>
<script src="scripts/services/itemService.js"></script>
<script src="scripts/controllers/contactController.js"></script>
<script src="scripts/controllers/itemController.js"></script>
<script src="scripts/controllers/navbarController.js"></script>
<script src="scripts/directives/directives.js"></script>
</body>
</html>
the app.js
angular.module("iShareApp", ["ngRoute","ngAnimate"])
.config(["$routeProvider", function($routeProvider,locationProvider){
console.log($routeProvider);
$routeProvider
.when("/contacts", {templateUrl:"views/contacts.htm",
controller:contactController })
.when("/contactDetail/:contactId",
{templateUrl:"views/contactDetail.htm", controller: "contactController" })
.when("/items", {templateUrl:"views/items.htm",
controller:"itemController" })
.when("/itemDetail/:contactId",
{templateUrl:"views/itemDetail.htm", controller:"itemController" })
.otherwise({redirectTo:"/contacts"})
}]
the contactController (just the relevant part injecting data from the
service)
angular.module('iShareApp')
.controller("contactController",
function($scope,contactFactory,$location,$routeParams,arrayService){
$scope.contacts = contactFactory.getContactData();
}
);
and the contacts.htm view
<h1>Contact lijst</h1>
<div class="row">
<div class="span2"><input focus></div>
<div class="span2"><input ng-model="newContact.firstName"
placeholder="Voornaam" focus></div>
<div class="span2"><input ng-model="newContact.lastName"
placeholder="Achternaam"></div>
<div class="span2"><input ng-model="newContact.address"
placeholder="Adres"></div>
<div class="span2"><input ng-model="newContact.addressNr"
placeholder="Huisnr"></div>
<div class="span2"><input ng-model="newContact.city"
placeholder="Woonplaats"></div>
<div class="span2"><input ng-model="newContact.telephone"
placeholder="Telefoon"></div>
<div class="span2"><button class="btn-large btn-success"
ng-click="addContact()">Toevoegen</button></div>
</div>
<div>
<div class="row cardContainer">
<div class="span3 card" ng-repeat="contact in contacts| filter:name
| orderBy:'-name'">
<button class="btn close cardClose"
ng-click="deleteContact(id)">×</button>
<div class="cardHeader">
{{contact.firstName}} {{contact.lastName}}
<div class="glyphicon glyphicon-pencil btn"
ng-click="editContact(contact.id)"></div>
</div>
<div class="cardBody">
<div>{{contact.address}}
{{contact.addressNr}} {{contact.city}}</div>
<div>{{contact.telephone}}<div class="glyphicon
glyphicon-plus btn" ng-click="itemDetail(contact.id)"></div></div>
</div>
<div>
</div>
</div>
Notes:
In the process of fixing I changed in index.htm the AngularJS and JQuery
includes from bower_components to CDN sites
<script
src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.js"></script>
<script src="http://code.angularjs.org/1.2.11/angular.js"></script>
<script
src="http://code.angularjs.org/1.2.11/angular-animate.js"></script>
<script
src="http://code.angularjs.org/1.2.11/angular-route.js"></script>
The directive waiting used in index.htm (<waiting>Just a
moment...</waiting>) does work, I see no errors in FireBug other than
Why isn't the view in index.htm showing???
Any help much appreciated!!!
Marc
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.