Search Posts

Category: controller

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 […]

ng-click not working while calling a function on a ‘ul’ in angularJS

I’m creating a navigation menu using angularJS. My ng-click with the function “sayHello()” inside the ul or li are not working. However, all the other ng-click are working fine. ALso, if I just remove ‘obj.showChildMenu = !obj.showChildMenu’ from my first ng-click in the ul and just include ‘sayHello’ there, it is not working. But the one which shows = ‘obj.showChildMenu = !obj.showChildMenu’ seems to work fine. I’ve only attached the sample code here. The controller […]

AngularJS SET service variable in controller, and use GET it everywhere else without $watch

Here is my basic service to SET and GET the value: .service(‘companyService’, [ function () { var self = this self.options = {} function CompanyService () { self.setOptions = function (newObj) { self.options = newObj } } return CompanyService() }]) In the global controller I call my $api factory which makes an http request (with promise) to get and set Company Options. I do this only once. .controller(‘global’, [‘$scope’, ‘$http’, ‘$api’, ‘$location’, ‘$translate’, ‘$rootScope’, ‘$timeout’, […]