Posts

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 class AdminController { private static final Logger logger = LoggerFactory.getLogger(AdminController.class); @RequestMapping(value=...

Check if Current Time is Between Opening & Close Times with Angularjs

I’m trying to indicate if a business is open given the current time of day, an open time, and a close time. Here’s my time format. $scope.open = "1970-01-01T13:00:00.000Z"; // We can ignore the dates $scope.close = "1970-01-02T22:00:00.000Z" Is there a simple & surefire way to determine this in Angularjs? Something like <div ng-if="currentTime >= open && currentTime < close"></div> I have found several moment libraries that could possibly handle this, but I feel like importing a whole library is overkill for a basic time comparison, and most of the javascript solutions I’ve come across don’t handle this time format. Any input is appreciated! Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/22/check-if-current-time-is-between-opening-close-times-with-angularjs/ via @lzomedia #developer #freelance #web #lzomedia.com

is it possible not to execute the promise (.then ()) in the controller when there is an error in a web request?

I’m currently using a factory called http that when I invoke it, I make a web request. this receives as a parameter the url of the web request. app.factory('http', function ($http) { var oHttp = {} oHttp.getData= function (url) { var config={ method: 'GET', url: url } return $http(config).then(function(data) { oHttp.data=data.data; },function(response) { alert("problem, can you trying later please?") }); } return oHttp; }); function HelloCtrl($scope, http) { http.getData('https://www.reddit.com/.json1').then(function(){ if(http.data!=undefined){ console.log(http.data) } }) } I would like the promise not to be executed on the controller if the result of the web request is not satisfied or there is a problem. is there any better solution? I want to avoid doing this every time I make a web request, or do not know if it is the best way (see the if ): //I am putting "1" to...

Array attribute not parsing to angularjs Directive

My directive is angular.module('app').directive('authorDirective',authorDirective); function authorDirective() { return { restrict: 'E', scope: { Authors: '=', details: '&', name : '=' }, replace : true, template: '<table class="table"><thead>'+ '<tr><th>Name</th><th>Nationality</th><th>Dates</th></tr></thead>'+ '<tbody ng-repeat="model in Authors">'+ '<tr><td></td><td></td><td></td></tr>'+ '</tbody></table>' }; } Controller is angular.module('app').controller('LabController',LabController); function LabController () { var vm = this; vm.Authors = [ {Name : "Mark Twain",Na...

are these ui-sref states ie11 friendly

When trying to navigate with IE11, the links do not work with a state such as url: '/main-category/:id' but the “parent” state url: '/:main-category/' works fine. These are not true nested or parent-child since they don’t actually share any common views/html template, except for navigation. I found this meta tag suggestion and this IE events suggestion, but neither seem to be providing a solution for why my navigation bar AND links from another state do not function. Here is a live site without minify, to test compare IE11 & all other browsers. So, are these routes correctly setup? router.js angular.module('app_litsco') .config(['$stateProvider', '$urlRouterProvider', '$locationProvider', function ($stateProvider, $urlRouterProvider, $locationProvider) { $urlRouterProvider.otherwise('/'); $stateProvider .state('home', { //this state works url: '/', ...

Angular 4. What is :host in angular CSS?

I have trouble understand the concept of :host selector in Angular CSS. What exactly does it do? I looked at here https://angular.io/guide/component-styles . It starts talking “host element” and “parent component” which are equally confusing since I can’t find a concrete definition online. What exactly is host element? What makes a component a parent component? Then there is an example of :host on this blog: https://www.concretepage.com/angular-2/angular-2-4-component-styles-host-host-context-deep-selector-example But it looks like :host just creates a bunch of rectangles on top of each other?? It said “The style written in :host selector in CompanyComponent will be applied in host element in PersonComponent and so on” But what style is applied? It just create a rectangle with :host and paste it on other template Please I need help. Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/22/angular-4-what-is-host-in-angular-css/ via @lzomedia #develop...

Web application architecture with zend framework 3 and AngularJS

Image
I am building a web application with Zend Framework(backend) 3 and AngularJS 1.6.x. I have created a project architecture for the application. I have saved the angular app inside the public directory of the zend framework. Is this a valid and secure architecture? Should i move the files like node_modules outside the public directory? Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/22/web-application-architecture-with-zend-framework-3-and-angularjs/ via @lzomedia #developer #freelance #web #lzomedia.com

Force angularjs attribute directive to not parse its value

I am making an attribute directive that will work similarly to ng-if . window-match-media="(min-width: 400px)" which will make the element render if the media query matches and disappear otherwise. I am modeling my directive on the code for ngIf It works great with the exception that I have to currently enclose the media query in an extra pair of quotes. This is because without it, it seems to try to parse the attribute value . This makes sense for ngIf but in my case I want to simply treat the value as a string. I see nothing in the ngIf codebase that would allow me to indicate that the value should not be parsed, and adding scope: { windowMatchMedia: '@', }, does not help (I’m not sure attribute directives can isolate scope anyways?). I access the value via the $attributes parameter to the directive’s link function which always does seem to provide it as a string, but if I do not specifically make it one with quotes ie window-match-media=...

AngularJS callback error and is not a function

I have an error in line callback(response.data) telling that callback is not a function . Well, I am new to this and I am trying to figure out how to fix this issue but I am having a tough time. Any idea is appreciated. Thanks app.service('NotificationPollService', function ($q, $http, $timeout) { var notification = {}; notification.poller = function (callback, error) { return $http.get('api/sample.php').then(function (response) { if (typeof response.data === 'object') { callback(response.data); } else { error(response.data); } $timeout(notification.poller, 2000); }); } notification.poller(); return notification; }); Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/22/angularjs-callback-error-and-is-not-a-function/ via @lzomedia #developer #freelance #web #lzomedi...

How to place the md-sidenav handler as child of sidenav himself

I am interested into know id if possible (based on this example ) put the Toggle right button as child of the right md-sidenav , this should keep fixed in respect to the parent bu keeping visible when sidenav is closed. This is an example: https://devitems.com/html/subas-preview/subas/index-2.html Regards and thanks in advance. Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/22/how-to-place-the-md-sidenav-handler-as-child-of-sidenav-himself/ via @lzomedia #developer #freelance #web #lzomedia.com

Accessing port 4200

Image
Kindly help me… When I try to host,it shows error message like this Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/21/accessing-port-4200/ via @lzomedia #developer #freelance #web #lzomedia.com

why providerRoute is not working

var app = angular.module('MyApp', ['ngRoute']); app.config(function ($routeProvider) { $routeProvider .when("/Home", { templateUrl: "Home/EmployeeList", controller: "listController", }) .when("/Home1", { templateUrl: "Home/EmployeeTable", controller: "tableController", }) .otherwise({ redirectTo: "/Home/Index" }) .controller("listController", function ($scope) { $scope.message = "In list controller"; }) }); why on running code TypeError:routeProvider.when(…).when(…).otherwise(…).controller error shows in cosole. Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/21/why-providerroute-is-not-working/ via @lzomedia #developer #freelance #web #lzomedia.com

HTML cache manifest and dynamically loaded images

I have a web app with offline functionality. I managed to get the manifest working properly with all the required assets; css, js and images. However I use angular to get from the server a list of user generated images, in a similar manner: $scope.images = angular.fromJson(localStorage.getItem('images')) || [] $http .get('/my-rest-endpoint') .then(function(res){ $scope.images = res.data localStorage.setItem('images', angular.toJson(res.data)) }).catch() I use the localStorage to keep the list even if the user is offline, however I would like to have these pictures included in my offline cache… Any idea how to achieve this? BONUS: In the future there may also be video files. What to do in that case? Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/21/html-cache-manifest-and-dynamically-loaded-images/ via @lzomedia #developer #freelance #web #lzomedia.com

ng-show doesn’t work correct with value boolean

I have one issue like that: <input type="text" ng-model="keyword" ng-change="filterItemByName()"> <ul class="suggestion-list dropdown-menu" ng-show="isSearching"> <li ng-repeat="item in list"> <span ng-click="handleAction(item);"></span> </li> </ul> And here is the js: $scope.isSearching = false; $scope.filterItemByName = function(){ //handle for searh item $scope.isSearching = true; }; $scope.handleAction = function(item) { console.log(item); $scope.isSearching = false; }; The problem in here is, when input the keywork, my app will call an request to get the list (suggestions), but when i click on the item in the list, nothing happend, it doesn’t log anything, it didn’t call handleAction as is. I just found the problem related about the $scope.isSearching, when we show like above, the ng-click doesn’t trigger. But if i do : <ul class=...

ng-model not work within ng-if and ng-repeat, AngularJs?

I have the following template: <tr ng-repeat="dailyInformation in TradodModel.Model.EmployeeDayRelatedData.DailyInformation track by $index" ng-click="DailyInformationRowOnClick(dailyInformation, $event)" data-selected="" data-rowindex=""> <td ng-if="!IsHourlyContract() && DailyOverShowType() != @((short) DailyOverShowTypeEnumeration.NotShow) && !DailyOverType()" data-changed="" title="" class=""> @if (ViewBag.HasWritePermission) { @Html.BootstrapTimeTextBox("OverTimeTextBox", "", false, false, 2, false, new Dictionary<string, object> { {"data-disableindexing", "true"}, {"ng-if", "DailyOverShowType() == " + (short)DailyOverShowTypeEnumeration.Editable}, {"ng-model", "d...

I want to move focus left right up down in html table

this is C# loops which create html table string from controller for (int j=0; j< ds.Tables["tblMaster"].Rows.Count;j++) { html += " <tr>"; //cell for customer name html += "<td class='bg-primary' onclick=CashMemo('"+ fromDate +"','"+ ToDate +"',"+ ds.Tables["tblMaster"].Rows[j]["intPoductId"].ToString() +","+ ds.Tables["tblMaster"].Rows[j]["intCustomerId"].ToString() + ")>" + ds.Tables["tblMaster"].Rows[j]["varName"].ToString()+"</td>"; if (ds.Tables["tblMaster1"] != null) { ds.Tables["tblMaster1"].Clear(); } string query1 = ""; //product id ...

Angularjs ngresource getting peoblems for promise and resolve

I have a controller and there I call a service. var rowCollection=[]; allCars.car('getAllcarList').getAllcarList({}).$promise.then(function(data) { rowCollection.push(data.cars); }); console.log(rowCollection); After the service call If i want to use the rowCollection it shows undefined as the response till not come.How to stop execution until response come. So that the variable can use any where in the program. In my service I have code like this function($resource) { var apiResourceUrl='http://127.0.0.1/stock/api/public/index.php/'; var factory = {}; factory.allCars= function(queryType) { var hsRESTUri = apiResourceUrl; if (queryType == 'getAllcarList') { hsRESTUri = apiResourceUrl + 'getAllcarList'; } return $resource(hsRESTUri, {}, { getAllcarList: { method: 'GET', } }); }; return factory; Sourc...

Check that token is valid or invalid using jwt

Hey I have one small problem with token in app. I have middleware to check token in next routes and I use tokne to isLoggedIn function in angular to check logged users. But if I change token in local storage user still is logged because token still exist but is invalid. Could you help how I can response from middleware that token is valid or invalid and next check this in angular? Question: How check that token is valid or invalid in angular? e.g. if token is invalid change route location Please look on my code: middleware router.use(function(req, res, next){ var token = req.body.token || req.body.query || req.headers['x-access-token'] if(token){ jwt.verify(token, secret, function(err,decoded){ if(err){ res.json({success:false, message:'Invalid token'}) } else { req.decoded = decoded; next() } }) } else { res.json({ success: false, message:'No token provided' }); } }); factory...

Spring Boot ngRoute

I’m trying to make a single page application with a Spring back end and an AngularJS front end. I’ve followed tutorials and looked up similar questions but ngRoute just doesn’t seem to work with a Spring back end (I got it to work with a NodeJS back end). index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"/> <title>Spring Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js"></script> <script src="../static/index.js"></script> </head> <body ng-app="index" ng-controller="indexController"> <a href="/test">test</a> <div ng-view=""></div> </body> </html> test.html <div> Template lo...

Is this image confirms me that i have definately installed angular CLI globally or not?

Installation of Angular CLI globally Does it surely mean that angular CLI globally is installed on my ubuntu ?? Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/21/is-this-image-confirms-me-that-i-have-definately-installed-angular-cli-globally-or-not/ via @lzomedia #developer #freelance #web #lzomedia.com