Reputation: 196
I am in angular's world since few months and I always have instantiated my controllers such that:
First I create angular.module:
angular.module("dummyApp", ['some-directive']).config(...).run(...);
After I can create a controller in this module:
angular.module("dummyApp").controller("dummyCtrl", function($scope) {
// some logic here
});
(The correponding html is in place).
Now, I am starting with meteor and angular together. And when I try declare a controller the error is (and I know what it means):
Uncaught Error: [$injector:nomod] Module 'dummyApp' 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.
how on earth I do this in meteor? I try this and a lot variants with the same result. Could be that I don't use $meteor
? Syntax ControllerAs
?
It frustrates me that something so easy take my time.
Update
Index.html
<body ng-app="EyEnsure">
<div class="container">
<!-- Navbar goes here -->
<!-- Navbar goes here -->
<nav>
<div class="nav-wrapper">
<a href="#!" class="brand-logo">Logo</a>
<a href="#" data-activates="mobile-demo" class="button-collapse"><i class="material-icons">menu</i></a>
<ul class="right hide-on-med-and-down">
<li><a ui-sref="Map">Map</a></li>
</ul>
</div>
</nav>
<!-- Page Layout here -->
<div class="section card-panel teal lighten-2">
<!-- Aquí se insertan las vistas -->
<div ui-view></div>
</div>
<!-- end layout -->
Main.js:
angular.module("EyEnsure", ['angular-meteor', 'ui.router', 'uiGmapgoogle-maps'])
.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/");
$stateProvider
.state('Home', {
url: "/",
template: UiRouter.template('main.html')
})
.state("Map", {
url: "/map",
template: UiRouter.template('map.html'),
//controller: 'mapCtrl', // I tried this..
//controllerAs: 'map'
})
});
View where I would like show google map:
<template name="map.html">
<div ng-controller="mapCtrl">-->
<h1 class="center-align">Map to EyEnsure</h1>
{{tittle}}
<div class="party-details-maps">
<div class="angular-google-map-container">
<ui-gmap-google-map center="party.location || map.center"
events="map.events" zoom="map.zoom">
</ui-gmap-google-map>
</div>
</div>
</div>
MapController.js:
angular.module("EyEnsure")
.controller('mapCtrl', function($scope) {
$scope.tittle = "Hello!";
$scope.map = {
center: {
latitude: 45,
longitude: -73
},
zoom: 8,
events: {}
};
});
Just in case, my packages installed in .meteor/packages
:
meteor-platform
urigo:angular
angularui:angular-ui-router
netanelgilad:ng-cordova
angular:angular-material
materialize:materialize
urigo:angular-ui-router
angularui:angular-google-maps
Upvotes: 2
Views: 554