Miomir Dancevic Miomir Dancevic - 1 year ago 122
AngularJS Question

Angluar difference creating controller?

I am making some controller in Angular, when i created like this

aluPlanetApp.controller('KontaktController', function($scope) {
$scope.title= 'Kontakt';
$scope.id = '10';
$scope.users =[{"MIGX_id":"1","image":"upload/bridge.png"}];

It work ok, but when i try to make it like this, i got error

(function () {
'use strict';

aluPlanetApp.controller('KontaktController', KontaktController);

KontaktController.$inject = ['$scope'];

function KontaktController($scope) {
$scope.title= 'Kontakt';
$scope.id = '10';
$scope.users =[{"MIGX_id":"1","image":"upload/bridge.png"}];


function activate() { }

This error

TypeError: aluPlanetApp.config(...) is not a function
aluPlanetApp.config(function($routeProvider) {

This is link to see entire JS


Answer Source

Just get rid of aluPlanetApp variable completely and always use the getter version of angular.module()


See John Papa Angular Style Guide

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download