Search Posts

AngularJS accessing scope from $http.get function

I’m trying to change variable in scope from $http.get.then function, but it writes undefined. target.html loaded succesfully, I have tried and read response. $scope.loaded_view = “before”; $scope.getView = function(name) { $http.get(chrome.extension.getURL(“/views/” + name + “.html”)).then(function(response, stat, xhr) { $scope.loaded_view = “after”; }); console.log($scope.loaded_view); //–> before } $scope.getView(‘target’); Source: AngularJS

button resets only the selector but not the data related to the selected option

There is a table having a filter from which is possible to select an option of a dropdown menu and the table will show only the data for which type=selected type. there is also a button for resetting the selector to the first option. the problem that I have is that I can’t make these two functionalities run in the same time: the selector to update the data on the table the reset button to […]

dynamic checkbox Tree jquery not working

I ‘m new to angular js, i want to implement dynamic checkbox Tree in modal to my project using angular js and jquery . this my controller: UsersController.js function UsersController($scope, toastr){ $scope.mockData = { item:{ id: ‘id1’, label: ‘Lorem ipsum dolor 1’, value:1, checked: false }, children: [{ item:{ id: ‘id11’, label: ‘Lorem ipsum dolor 11’, value:1, checked: false } },{ item:{ id: ‘id12’, label: ‘Lorem ipsum dolor 12’, value:1, checked: false } },{ item:{ […]

Convert Angularjs Directive to angular 4 component

Kindly someone help me to convert this angularjs directives to angular 4 component also give some description so it can help me to other directives as well thanks. app.directive(‘cardTitle’, [‘$compile’, function ($compile) { var directive = { restrict: ‘E’, scope: { topics: ‘=’, objHandle: ‘=’, configData: ‘=’ }, templateUrl: ‘/app/home/cardtitle.html’, controller: [‘$scope’, ‘enum’, ‘common’, controller] }; return directive; function controller($scope, e, common) { $scope.e = e; var topicsHtml = “”; $scope.getHtml = function (topics, entityIdentifier, […]

AngularJS: ngModel $formatters gives undefined

Here is an example of phone formatter I designed: (function () { /* @ngInject */ function MyPhoneDirective($filter) { return { restrict: ‘A’, require: ‘ngModel’, link(scope, element, attributes, ngModel) { ngModel.$parsers.push((modelValue) => { modelValue = modelValue.replace(‘ ‘, ”); ngModel.$modelValue = modelValue; return modelValue; }); ngModel.$formatters.push((viewValue) => { console.log(viewValue); // gives undefined viewValue = $filter(‘phoneFormatter’)(viewValue); ngModel.$viewValue = viewValue; return viewValue; }); }, }; } angular .module(‘module.common’) .directive(‘myPhone’, MyPhoneDirective); }()); And here is a usage example <input type=”text” […]

Unit testing HTTP manager wrapper service

I have an HTTP manager wrapper service, which I is getting used by api services internally. Not I am wondering How I can test this wrapper services. any suggestions? angular.module(‘PpmApp’) .factory(‘httpManager’, [‘$injector’, httpManager]); function httpManager($injector) { var $http = $injector.get(‘$http’); var $q = $injector.get(‘$q’); var preloaderService = $injector.get(‘preloaderService’); var constantsProvider = $injector.get(‘constantsProvider’); var service = { getRequest: getRequest, postRequest: postRequest, putRequest: putRequest, deleteRequest: deleteRequest, fileUpload: fileUpload }; var loader = true; return service; function getRequest(params) […]

ng-show does not hide a button

I have a selector with more options, I want to hide a button if the first option of the selector is selected. <select ng-model=”$ctrl.type”> <option value=””>none</option> <option value=”1″>1</option> <option value=”2″>2</option> </select> as it can be seen, the first option has value =””. This is the button: <div ng-show=”$ctrl.type!=””” class=”btn action-btn” ng-click=”$ctrl.doSomething()”> my button </div> inside the controller I have this code: class MyCtrl { constructor(…) { … } doSomething() { this.type = “”; } } […]

How to send the path using Angularjs?

I’m getting the path of the files in ng-repeat. When I click on each file i should send the same path back to backend. so the new files should be updated by refreshing the div.How can i acheive that ? <div ng-repeat=”t in main.path”> <div style=”text-transform:capitalize”><span class=”glyphicon glyphicon- folder-close”style=”padding:10px”></span>{{t.name}}</div> </div> Source: AngularJS

Next Page »