Search Posts

Category: controller

how to give controller a name in a directive in Angular

So it might be a simple question. I have a directive defined this way: angular .module(‘ui-abc’, [ ‘xyz’]) .directive(‘computer’, compute); function compute( item) { return { restrict: “EA”, templateUrl: ‘../elements/src/template.html’, scope:{ qwerty : ‘=’,} controller: [‘$scope’,’$sce’, { ……… } The controller does not have a name, how can i add one ? I need this name so that I can refer to that controller inside my ui-router configuration. I tried to do this function compute( […]

Angularjs $http spring rest controller – 404 error

I am getting 404 error on making a $http call from angularjs to spring controller, here is the code : Factory : factory.checkCodeAvail = function(url){ return $http({ url: url, responseType:”json”, method: “GET”, headers: { “Content-Type”: “application/json” } }); } This factory method is called by controller : commonFactory.checkCodeAvail(‘findDepartment’) .then(function (success){ console.log(success); },function (error){ console.log(error); }); This is the error i m getting in browser console : GET http://localhost:8080/TexERP/findDepartment 404 () Spring controller : @RestController public […]

Angularjs Google Map API Integration

I’m trying to add a google map in angular JS… and have been struggling. I didn’t want to use one of the angular dependencies, but simulate the ‘async defer’ on the Google JS API site. I’m pretty new to Angularjs but get the concept of keeping things assigned to the controllers scope. Pretty sure it’s just something dumb, but not sure what… any help would be awesome 🙂 (function () { ‘use strict’; app.controller(‘travelCtrl’, [‘$scope’, […]

Scope in custom Directive in AngularJS for checking if a value already exists in DB

I have a problem of scope in my custom directive created for checking if an email already exists in the DB. Indeed the results retrieved by the AJAX query are not returned in the scope (and in my template). For implementing that I follow a solution for checking if an email is already present in the DB: defined in this topic angularjs: custom directive to check if a username exists In my application a user […]

Uncaught Error: [$injector:modulerr] Failed to instantiate module

I am getting a “failed to instantiate module” error when trying to inject and use an Angular service that I wrote. I have an HTML page that calls an API. I need to be able to take the return value from the API and store it for use in another controller. Here is the HTML page: <!doctype html> <html ng-app=”auth”> <head> <title>Login AngularJS</title> </head> <body> <div ng-app=”auth” ng-controller=”Login”> <form method=”post” ng-submit=”login()” novalidate ng-controller=”Login”> DBID<input type=”text” […]

How do I access my angular controller when handling a browser ‘full screen’ event?

Inside my angular controller (which is a controller that’s used for a Google maps directive), I’m adding an eventlistener on the document element like this, so I can detect a change to the browser’s ‘full screen’ mode using the full-screen API: if (document.addEventListener) { document.addEventListener(“webkitfullscreenchange”, this.fullScreenChangeHandler, false); document.addEventListener(“mozfullscreenchange”, this.fullScreenChangeHandler, false); document.addEventListener(“fullscreenchange”, this.fullScreenChangeHandler, false); document.addEventListener(“MSFullscreenChange”, this.fullScreenChangeHandler, false); } I’m then handling the event like this in my fullScreenChangeHandler method, which is a method that also sits […]

change ngview from within function

I am using templates to build my app. Basically have one main page, and then I am loading others pages thru it using ng-view. The href links in the index.html work fine. But I also want to be able to change ng-view within js functions as well. How is this done? I tried to go to the red page using $location.path, but nothing seems to happen besides printing to the console. Before that i tried […]

Jhispter : angular prints null entity while retrieving objects after 1

angular .module(‘smartLpcApp’) .controller(‘CaptionsDetailController’, CaptionsDetailController); CaptionsDetailController.$inject = [‘$scope’, ‘$rootScope’, ‘$stateParams’, ‘entity’, ‘Captions’, ‘Projects’]; function CaptionsDetailController($scope, $rootScope, $stateParams, entity, Captions, Projects) { var vm = this; vm.captions = entity; console.log(“Printing entity : “+JSON.stringify(entity)); vm.load = function (id) { Captions.get({id: id}, function(result) { vm.captions = result; }); }; var unsubscribe = $rootScope.$on(‘smartLpcApp:captionsUpdate’, function(event, result) { vm.captions = result; }); $scope.$on(‘$destroy’, unsubscribe); } I am using Jhipster 1.8.5 and angular 1.5.2. This controller gets entity and displays it.While retrieving […]

AngularJS ng-view not showing up using $routeProvider templates

Directory Structure: public film – film.html – film-controller.js main – main.html – film-controller.js – app.js – index.html In my index.html file I have: <div ng-view> </div> in the body and ng-app=”myApp” in the starting html tag app.js angular.module(‘myApp’, [‘ngRoute’]).config(config); function config($routeProvider) { $routeProvider.when(‘/’, { templateUrl: ‘main/main.html’, controller: ‘MainController’, controllerAs: ‘vm’ }).when(‘/film/:id’, { templateUrl : ‘film/film.html’, controller: ‘FilmController’, controllerAs: ‘vm’ }).otherwise({ redirectTo : ‘/’ }); } In main.html I have a <h1>Hello {{}}</h1> line of code […]

Next Page »