Search Posts

Category: javascript

angularJs – handling an error and setting property of the child scope

I’ve been thinking about this problem for some time and could not figure out a solution so asking for help here. Our application app.js file has several http errors interceptors. They have the following line in them $rootScope.$broadcast(“sm:serverError”, errors); The serverError directive is added to the layout.html file which is used in all our index pages (e.g. main lists). From the index page we open the edit form and in the edit form we have […]

Child controller trigger before parent completes all resolve in UI-Router

I have a parent route called engine. Here I am validating token, loading all db stuff, checking boolean values and navigating to different routes based on data. This whole process works fine if I navigate from parent to child but when I refresh child route its controller init function trigger first before parent resolve got finished. Here is my sample code angular.module(‘demoApp’, [‘ui.router’]) .config(routes); function routes($urlRouterProvider, $stateProvider) { $urlRouterProvider.otherwise(‘/engine/121212’); $stateProvider .state(‘engine’, { url: ‘engine/:token’, template: […]

Cancel event on change of option from dropdown

I have below code where I am taking confirmation on change of select from the dropdown. If the user selects any option from the list and then click on cancel, I want to change the option to default “select any one” on cancel event of the confirmation alert. Currently what gets selected is chosen as default. $scope.GetValue = function(newObj, oldObj) { var dialog = confirm(‘Continue?’); if (dialog) { alert(“Changing from “+oldObj+”to “+newObj); } else { […]

set a group of similarly named attributes to false

In an AngularJS project, the view model has several properties associated with navigation that begin with the word “show”. There is a function that sets these to false when called: var hideComponents = function() { vm.showAddress = false; vm.showEvent = false; vm.showAccount = false; //several others not displayed here } Is there a way to use a wildcard to set all of the properties that begin with the word “show” to false? I was thinking […]

JavaScript- Not showing the Title in Text Accordion

At first Please see the screenshot , here i am working on Accordion text Editor, where you can add title and body text. when i clicked ADD button multiple time then showing like this type. Not showing the title text. i thing it’s problem on JS file. Does any solution?? Thanks in Advance! $(document).ready(function() { $(‘#Add_btn’).click(function(){ $(‘#accordion_body’).append($(‘#editableDiv’).html()); var x = document.getElementById(“accordion_input”).value; document.getElementById(“accordion_title”).innerHTML = x; }); }); function myAccorFunction() { var Myaccordion = ‘<div class=”Myacc” id=”acc_main” […]

AngularFirebaseAuth : Calling server api just after firebase auth?

My auth is based on 2 things : firebase auth (email/password) call on a server API to retrieve full customer entity from BDD and from firebaseID (user must exists) So a user will be “authenticated” if these two conditions are met. I also have authGuards based on a isAuthenticated() returning an Observable (because on a page refresh, guard must wait for the auth to be finished before redirecting the user anywhere). Problem : I can’t […]

Can an angularjs directive compile a new element which is assigned a second directive

EDIT: Each of the directives below will need to apply ng-model bindings in the elements they create to whatever controller is assigned to the page they are on. I’ve updated the code to reflect that. I’m trying to create some dynamic HTML using directives. A simple case worked fine in the case of a single directive but now I’m trying to get a little fancier and I’m not sure how this should work. Looking at […]

Angular JS Unit testing: how to test function in service that doesn’t return

I’m sorry for possible duplicate, I didn’t find any solution for my problem. I’m need to write tests for a service in Angular JS app. So I have one main function that returns and uses as an external method. And a couple help functions for external. So how can I call and test things inside help functions (subFunc)? service.js function TestService() { return { mainFunc: mainFunc }; funcion mainFunc() { //do some and call subFunc() […]

Md-chips email validation

Md-chips email validation How to create an email validation for md-chips? My expression below is not working, since, the ng-keypress directive is called whenever I type something. Suggestions? <div class=”row”> <div class=”col-md-12″ ng-cloak=””> <md-context class=”md-padding”> <md-chips md-separator-keys=”ctrl.customKeys” ng-keypress=”ctrl.validateEmail()” ng-model=”ctrl.ConfiguracaoRegra.Emails” md-max-chips=”20″ placeholder=”Inserir um email…” ng-required=”true” type=”email”></md-chips> </md-context> </div> </div> vm.validateEmail = function (keyEvent) { var emailValue = angular.element(“.md-input”).val(); var reg = /^[_a-z0-9]+(.[_a-z0-9]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$/; if (reg.test(emailValue)) { vm.isEmailValid = true; } else { vm.isEmailValid = false; } }; […]

Nodejs + API Rest Structure

I have a legacy system that provides an api with some queries in rest/json (Delphi) in which I will need to consume this data already available. Then build an app using angular + nodejs, and I would like my application (client) to communicate only with my web-server on nodejs, and the web-server nodejs communicate with api, I will try to explain. MyApp -> web-server NodeJS -> api rest legacy client -> (web-server NodeJS port 80) […]

Next Page »