Posts

Angularjs – WYSIWYG image resize manually

How i want to resize image inside WYSIWYG editor when user upload image? I manage to insert into editor but i cant resize the image. Below is my code : http://embed.plnkr.co/yxMbI54wYUlxu2hSpfw8/preview Appreciate your advice. Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/16/angularjs-wysiwyg-image-resize-manually/ via @lzomedia #developer #freelance #web #lzomedia.com

How to make multiple request in a loop in agularjs2 in Ionic?

I have to copy an online database to offline database using an API call with post method. one API call returns 12 records and number of total records are unknown. To do that I wrote the following code and when I ran it, it never stopped. function should stop when the result is empty. but its not stopping, I think it is the issue with asynchronous nature of JavaScript. Anyone who can suggest a solution. I am new to angularjs and Ionic. getProducts() { var flag = true; let headers = new Headers(); headers.append('Content-Type', 'application/json'); headers.append('token', this.token); let options = new RequestOptions({ headers: headers }); var body = {"categories":[0],"tags":[0]}; var productCount = 0; while(flag) { console.log("Products Call"); var url = "http://url" this.http.post(url, body, options) .map(res => res.json()) .subsc...

Convert string "12:00:34" time to angular js time 12:00:34

Image
image show the model in which time will be shown but right now it is not properly binding Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/16/convert-string-120034-time-to-angular-js-time-120034/ via @lzomedia #developer #freelance #web #lzomedia.com

My ng-click is not invoking the action in the controller

I am using Asp.Net MVC and angular. I have this in my ‘print-script.js’ var MyApp = angular.module("MyApp", ['PrintService']); MyApp.controller('PrintController', function ($scope, PrintApi) { $scope.addData = function() { alert("SDFS"); var dataToAdd = { 'Name': $scope.name, 'Mobile': $scope.mobile }; PrintApi.AddData(dataToAdd) .then(function(response) { alert(dataToAdd.Name + " - " + dataToAdd.Mobile); }, function(error) { alert('An error occured: ' + error.message); }); } }); and this code in my ‘print-service.js’ var PrintService = angular.module('PrintService', []); PrintService.factory('PrintApi', function ($http) { var urlBase = "http://localhost:56720/"; var PrintApi = {}; PrintApi.AddData = function (qrDa...

Checking asynchronous values with a loop of $http calls

On my page I have a form of inputs that take in URLs <div ng-repeat="parent in parents"> <input ng-model="parent.url" type="text" /> </div> <button ng-click="addParent()"> Add new link </button> Later I have a button with ng-click that calls a function in my controller, which checks ( asynchronously ) if the pages with those URLs exist, along with some other ( synchronous ) checks. Somehow I need to wait for results to process, collect them and then display some content depending on those results. I tried looping over all $http calls for each URL: var results = []; for (let i = 0; i < parents.length; i++) { let p = parents[i]; $http.get(p.url). then((res) => { // pages exists results.push(true); }, (err) => { // page doesn't exist results.push(false); }); } But this would return an empty list, since $http calls are asynchronous. Then I can’t really check all of my results...

angularjs scope.$watch and expression with square brackets

I have found some legacy code in the product that I work on: $scope.$watch("[timeRange]", function() { doStuff(); }, true); timeRange is an object on the scope. I don’t understand this syntax of watching something with square brackets round it. I have searched the web and the angularjs documentation and still can’t work it out. Can someone help explain what this construct means? Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/16/angularjs-scope-watch-and-expression-with-square-brackets/ via @lzomedia #developer #freelance #web #lzomedia.com

How to edit online document in local editor?

I need to edit online document in my local editor (Eg; LibreOffice). I have a document repository and I have to add this new functionality to edit documents in the local editor. When the user saves the document, it is uploaded to the server. Do you know any way to do it? Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/16/how-to-edit-online-document-in-local-editor/ via @lzomedia #developer #freelance #web #lzomedia.com

How to add different inputs values into array of objects dynamically in angualrJs

I have multiple input fields under different headings:- <label>User</label> <input type="text" ng-model="a.arr.username"/> <input type="text" ng-model="a.arr.userdob"/> <input type="text" ng-model="a.arr.userpanNo"/> <label>Employee</label> <input type="text" ng-model="a.arr.empname"/> <input type="text" ng-model="a.arr.empdob"/> <input type="text" ng-model="a.arr.emppanNo"/> <label>Daily Workers</label> <input type="text" ng-model="a.arr.dwname"/> <input type="text" ng-model="a.arr.dwdob"/> <input type="text" ng-model="a.arr.dwpanNo"/> I want to save above data in the format:- [{a.arr.username:any value,a.arr.userdob:any value,a.arr.userpanNo:any value},{a.arr.empname:any value,a.arr.empdob:any v...

Angular JS Service not hitting server

I have created this service . and using enrollments.getProperty(); this statement to call this service but its not working i’m new to angular-JS please let me know where i’m making the mistake. var helloAjaxApp = angular.module("myApp", []); helloAjaxApp.service('enrollments', [ '$scope', '$http', function ($scope, $http) { $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=utf-8"; var enrollments = null; enrollment(); $scope.enrollment=function () { $http({ url : 'enrollments', method : "GET" }).then(function(response) { enrollments = response.data; alert("enrollments"); }); }; return { getProperty: function () { return enrollments; }, setProperty: function(value) { enrollments = value; } }; }]); Source: AngularJS from Angu...

AngularJS is not a function error

I am trying to implement a payment system in my e-commerce web application where I need installment options to be chosen by the client. I use angularjs to get that information but I get the error that all the provided functions below are not functions. I can provide additional information, but here is part related with the issue: $scope.tekcekim() = function () { $scope.strInstallmentCount = ""; }; $scope.taksit2() = function () { $scope.strInstallmentCount = "2"; }; $scope.taksit3() = function () { $scope.strInstallmentCount = "3"; }; Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/16/angularjs-is-not-a-function-error/ via @lzomedia #developer #freelance #web #lzomedia.com

dnd-drop and dnd-moved not working together

i user angular drag and drop list for pipeline system i found this link enter link description here i user the simple drop see my code <div class="col-md-2" dnd-list="val" ng-repeat="(key,val) in LeadList" dnd-drop="drop($index,key,val,item)"> <div class="panel panel-default"> <div class="panel-heading"> <h6 class="panel-title"></h6> </div> <div class="panel-body p-5" style="background:#F5F8FA"> <ul class="media-list"> <li class="media bg-white p-5" ng-repeat="item in val" dnd-draggable="item" dnd-mov...

what is the use of manual bootstrapping in Angularjs

I read in an article that the Angular JS application can be Manually Bootstrapped.What is the meaning of Manually Bootstrapping the Angular application and how is it done? Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/14/what-is-the-use-of-manual-bootstrapping-in-angularjs/ via @lzomedia #developer #freelance #web #lzomedia.com

Value in angular scope getting undefined

I have a scenario for deleting items. For this, first I get a list of values with particular condition. The retrieved values whill be shown in the UI with radio buttons to choose the particular item to choose for deleting. I have given the value for the radio buttons to be the id of the retrieved items. This id is used in angularJS method for deleting. Currently getting undefined value in the angular function inside the controller. My angular controller is as below: mainApp.controller("deleteToDoController", function($scope,$http) { $scope.toDoList = {}; $scope.getToDo = function(){ var url = "http://localhost:8080/webservice-4.0/rest/todo/"+$scope.status; $http.get(url) .then(function(response) { $scope.toDoList = angular.fromJson(response.data); }); } $scope.deleteToDo = function(){ var url = "http://localhost:8080/webservice-4.0/rest/todo/delete/"+$scope.deleteId; $http.get(url) .then(function(response) { ...

location is not updating in angularjs

I have an issue with $location.path . When i change my state it’s not updating. Here is my $stateProvider $stateProvider .state('state1', { url: 'url1', component: 'component1' }) .state('state2', { url: 'url2', component: 'component2' }); When i change my route the ui will update. Here is my index.html code <header></header> <div class="container-fluid" id="page-content" ui-view></div> <footer></footer> When i change any route view only update based on the state. I need to access the current state name in header & footer templates. Here is my header.js file contains, angular .module('myApp') .component('header', { templateUrl: 'header.html', controller: headerController }); function headerController($stateParams, $state, $location) { console.log($location.path()); console.log($state.current.name); } ...

Make a request for Json data inside a constructor of an Angular 4 home module?

I’m a total newbie into Angular/Typescript web development. I’m developing a website using ASP.NET Core 2.0 and Angular 4. It needs to fetch some data and present it at the homepage (that would be the home component of the Angular app). I’ve seen some examples and they suggest doing something like this: import { Component, Inject } from '@angular/core'; import { Http } from '@angular/http'; @Component({ selector: 'quotes', templateUrl: './quotes.component.html' }) export class FetchDataComponent { public quotes: Quote[]; constructor(http: Http, @Inject('BASE_URL') baseUrl: string) { http.get(baseUrl + 'api/quotes/recent').subscribe(result => { this.quotes = result.json() as Quote[]; }, error => console.error(error)); } } interface Quote { text: string; author: string; timeStamp: Date; } That code works fine when the component is not the first one to be presented when...

Display a customized confirm box in angularjs when user leaves a page

My requirement is to display a customized confirm box when the user leaves a page without saving form data. I used the window.onbeforeunload event it is displaying google chrome related predefined confirm box. When the user changes any form and trying to reload, tab close or route change I want to display a $mdDialog.confirm and asking user to leave the page or stay on the same page. How do I make one? Source: AngularJS from Angular Questions https://angularquestions.com/2017/10/14/display-a-customized-confirm-box-in-angularjs-when-user-leaves-a-page/ via @lzomedia #developer #freelance #web #lzomedia.com

Pass token in header for authentication in MVC and Web API

Integrating MVC app with Web API, Azure Users Authentication is done using OWIN, Want to remove authentication cookie and pass token in header for api call. how to do it? I use MSAL.cs file for Azure AD authentication. Want to pass token in api call header. first load MVC application page, after authentication call web api methods. I used following code for azure AD autherization, private async Task OnAuthorizationCodeReceived(AuthorizationCodeReceivedNotification notification) { // Extract the code from the response notification var code = notification.Code; string signedInUserID = notification.AuthenticationTicket.Identity.FindFirst(ClaimTypes.NameIdentifier).Value; TokenCache userTokenCache = new MSALSessionCache(signedInUserID, notification.OwinContext.Environment["System.Web.HttpContextBase"] as HttpContextBase).GetMsalCacheInstance(); ConfidentialClientApplication cca = new ...

Angularjs-probelm dont work $compile after get response of ajax

i created directive for making print page.this directive have template page that included button and print template(this have ngRepeat on Result object).print button was clicked fire “click” funciton in Controller of directive then ajax request send to server for get array of object that fill print tamplate. Mainpage.html <div ng-class="{'btn':true,'btn-warning':true,'disabled':disableBtn}" data-toggle="modal" ng-click="getdetail=true;" data-target="#detailModal">order detail</div> <print-order disable-btn="disableBtn" order="selectedItem"></print-order> print.template.html <a ng-click="ctrl.click()" ng-class="{'btn':true,'btn-info':true,'disabled':ctrl.disableBtn}" > print <i class="fa fa-print"></i> </a> <div id="printSection"...

Able to scroll the background list while ionicpopup is opened

I have an ionic popup inside the ionic modal when i press the popup it shows the popup but i could able to scroll the ionic modal list as well as able to do all the operations but if i use the ionic popup without ionic modal these background scrolls are restricted can anyone tell me why the background scrolling happens when ionic popup is used in ionic modal. 'use strict'; (function () { angular.module('main') .service('ModalService', ModalService); ModalService.$inject = ['$ionicModal', '$log']; function ModalService ($ionicModal, $log) { var init = function (tpl, $scope) { var promise; var a = $scope; $scope = a; promise = $ionicModal.fromTemplateUrl(tpl, { scope: $scope, animation: 'slide-in-up' }).then(function (modal) { $scope.modal = modal; return modal; }); $scope.openModal = function () { $log.log('openModal function got clicked', $scope); $scope.modal.show(); }; $scope.clos...

stop a function when I access another state

I have two controllers. a page called page1 and another called page2. on page1 I have a code that runs an animation.I have a function that calls itself infinitely. in this line. .each(‘end’, tick) when the animation ends, it start tick() again. function tick(){ console.log("hello"); . . . //line 190 paths.attr('transform', null) .transition() .duration(duration) .ease('linear') .attr('transform', 'translate(' + x(now - (limit - 1) * duration) + ')') .each('end', tick) //when the transition ends, it start tick() again } This is fine, because it is an infinite animation. I put console.log(“hello”) in the tick function, then every time this function is executed, the word “hello” is written to the console. so far so good !. when I change the controller, ie when I click to go to page2, my previous animation is still running, and I can still see the console.log(“hello”) of the function that is in my first controller. ...