Posts

Showing posts with the label angularjs

Prevent Page navigation - SweetAlert

Prevent Page navigation - SweetAlert I'm trying to replace the JS box dialog with sweet alert dialog box. At normal cases, it works perfectly. But, at the time of navigating the page on confirmation. It didn't work. JS box : var confirm = window.confirm("Warning! You may have unsaved data,it will be lost..!" + "n" + "Are you sure want to leave this page ?"); if (confirm) { $scope.$eval(event); //It prevents the page to nav ,until i confirm it. } else { event.preventDefault(); } It works. In case of sweetalert , I'm using the same scenario sweetalert $scope.validation = function(event) { //.... sweetAlert({ title: "Are you sure?", //Bold text text: "Your will not be able to recover this imaginary file!", //light text type: "warning", //type -- adds appropiriate icon showCancelButton: true, // displays cancel btton confirmButtonColor: "#DD6B55", ...

angularjs 6 python django rest framework crossdomain api call issue

angularjs 6 python django rest framework crossdomain api call issue I have configured django rest framework with python 3. And the API is working fine in postman. But am facing a cross domain issue, when I call this api through my angualar 6 project. OS: Mac OS I have included oauth2 for authentication. It works well with postman API Url: http://127.0.0.1:7777/api/v1/token/ Angular 6 website url: http://localhost:5000/#/login When I called this with angualrjs it shows the following error. Mozilla: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:7777/api/v1/token/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Safari: Failed to load resource: Origin http://localhost:5000 is not allowed by Access-Control-Allow-Origin. XMLHttpRequest cannot load http://127.0.0.1:7777/api/v1/token/. Origin http://localhost:5000 is not allowed by Access-Control-Allow-Origin. Chrome: Failed to load http://127.0.0.1:7777/ap...

Angularjs: ng-model setting value from controller

Angularjs: ng-model setting value from controller how to set value of ng-model with dot from controller? <input type=text" ng-model="user.latitude"> this doesn't work: $scope.user.latitude = myLat; use $scope.user = {latitude: myLat}; in your controller – guru Jun 4 '14 at 15:24 3 Answers 3 You need to create user object first: user $scope.user = {}; $scope.user.latitude = myLat; or shorter: $scope.user = {latitude: myLat}; yes, but this will clear other values of user, for example 'ng-model="user.name"', how to edit only 'user.latitude'? – user1824542 Jun 4 '14 at 15:35 ...

AngularJS scope return $$state

AngularJS scope return $$state I have a directive and in this directive I have a value that comes from my controller, here is my directive: angular .module('thermofluor') .directive('tablePlate', tablePlate) tablePlate.$inject = ['$timeout', '$q']; function tablePlate($timeout, $q) { var directive = { link: link, restrict: 'E', templateUrl: '/crims/thermofluor/experiments/table_plate.html', scope: { plate: '=' } }; return directive; function link(scope, element) { console.log("test"); var plate = scope.plate; console.log(plate); scope.letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']; scope.numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; experiments = ; experiments[scope.plate.experiment.well] = [scope.plate.experiment]; return; } } The problem is that when I console.log the scope I...

When showing a new growl in angularjs clear the old ones from view

When showing a new growl in angularjs clear the old ones from view I am working on growl.info() on angularjs and I have a question. How can I check if a growl exists in view (screen), when trying to add a new one? If a new one tries to be shown the previous one must be erased from screen. The code in controller is this: $scope.showInfo= function () { var info = "test"; growl.info(message.replace("{0}", info), { ttl: 50000 }); }; but note that ttl is important too. If no new growl tries to be shown, the first must live for a long period. Thank you in advance! 1 Answer 1 Firslty we add a public variable: $scope.growlMessge = null; and then we check if it has already a value (just to destroy it), before giving the new one $scope.showInfo= function () { if ($scope.growlMessage != null) { $scope.growlMessage.destroy(); } ...

How to manage order of custom directives with separate directive controllers

How to manage order of custom directives with separate directive controllers In my html page I have call multiple directives. My directives has their controllers in separate files. My issue is all directive's init functions are not called in order. <div> <directive-a ng-if="a==true"></directive-a> <directive-b ng-if="b==true"></directive-b> <directive-c ng-if="c==true"></directive-c> <div> I have placed console.log and it printed a,c,b sometimes c,b,a. Kindly suggest me how to manage order. i have tried priority but it is not worked. Can we place directives link function in a separate file. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Angularjs+jquery bootstrap-datepicker delegate not firing on first click

Angularjs+jquery bootstrap-datepicker delegate not firing on first click I have tried adding the datepicker dynamically on button click and I have delegated the datepicker click which is not working on the first click its getting fired on the second click the code I have tried are the following $scope.add = function() { var body =angular.element(window.document.body); body.append(` <div class="input-group date"> <input class="form-control input-sm" placeholder="dd/mm/yyyy"type="text"> <span class="input-group-addon"> <span class="fa fa-calendar"></span> </span> </div> `); } $(document).delegate("div.input-group.date", "click", function(){ $(this).datepicker({autoclose: true,orientation:"top"}); }); I couldn't find out the reason, thanks ...

Selecting from AngularJS dropdown in Protractor.

Selecting from AngularJS dropdown in Protractor. I have searched to forums over and over again - tried to make sense of some of what people have said, but the solutions never seem to fit my case. My problem concerns selecting an item from a drop down list that has been coded in AngularJS on a website. I am running automated tests using Protractor and a Selenium server. Right now I am running different scripts I have coded on various websites that have been coded in AngularJS. Its fascinating to see something I code fill out a form automatically - so cool! Unfortunately whenever I come across a drop down in my test I try and come up with a solution for hours and never have been able to figure it out. So I have come to stack!! This is the code I am working with it's actually jetblue's sign up website so if you want to take a look go here: https://trueblue.jetblue.com/web/trueblue/register/ The trouble starts on page two with the dropdowns - don't know how to fill out a single...