angularjs-scope

how to remove Unexpected request: GET data.json?

こ雲淡風輕ζ 提交于 2019-12-08 16:30:31
I am trying to use $httpBackend to test my $http request ..i AM getting this error Unexpected request: GET data.json No more request expected here is my testing code beforeEach(inject(function($rootScope,$controller,appfactory,_$httpBackend_) { $scope = $rootScope.$new(); $httpBackend=_$httpBackend_; ctrl = $controller('cntrl', {$scope: $scope}); fac=appfactory; modeSpy= spyOn(fac, 'mode').and.returnValue('a'); })); it('test true value',function(){ expect(true).toBeTruthy() }) it('check message value',function(){ $scope.toggle(); expect($scope.message).toEqual('naveen') }) it("tracks that the

Is there a way to pass the scope to a directive templateUrl: function?

我只是一个虾纸丫 提交于 2019-12-08 16:14:03
问题 I have a directive that I'm calling with in a loop. Each item in the loop has a FieldTypeId attribute, and depending on the value of FieldTypeId, I want to swap out the URL of the template. I feel that this is a better and polymorphic approach rather than doing an ng-switch statement in the html. <div ng-repeat="item in attributes"> <div attribute-input></div> </div> Of course, the $scope isn't available in this directive: editStudentAccountModule.directive('attributeInput', function () {

Change index of AngularJS md-tabs have no effect at all

感情迁移 提交于 2019-12-08 15:29:40
问题 In my Angular app, I have a md-tabs whose md-selected directive is binded to a property in my controller. I'd like to change the current tab to the one whose index is set by a function called by ng-click somewhere else in my template. I did it this way: <div ng-controller="TrackingCtrl" layout-fill> <md-content ng-if="isSmart" layout-fill> <md-tabs md-selected="selectedIndex" layout-fill> <md-tab>.........</md-tab> <md-tab>.........</md-tab> <md-tab>.........</md-tab> <md-tab> <md-tab-label>{

Directive inner content with isolated and non-isolated scopes

前提是你 提交于 2019-12-08 14:42:07
问题 I found quite a strange behaviour of scope:true type for inner content of a directive: <body ng-init="x=10"> <mydir> {{x}} </mydir> </body> so {{x}} is inner content, and directive definition is: .directive('mydir', function() { return { scope: {}, link: function(scope){ scope.x = 5; } }; }); When we define scope as isolated ( scope:{} ), it outputs {{x}} as 10, so uses outer scope. But when we create new scope for the directive( scope:true ), it will use it for inner content and output 5. So

Manually call $scope.$apply raise error on ajax call - Error: [$rootScope:inprog]

二次信任 提交于 2019-12-08 13:57:20
问题 I tried to use Angular Material md-autocomplete , the suggestion list was retrieved from Service Host via Ajax Call . Because of Delaying response , the $scope variable was not updating the UI Properly , it updates only is there is any event occur in the specific control. For Example Focus Sent Out and again Click the Control, then it updates the UI with the new value. My Exact issue snapshot is posted in md-items is not updating the suggesion list properly in md-autocomplete Angular Material

angular.element replaceWith not working

时光总嘲笑我的痴心妄想 提交于 2019-12-08 13:29:02
问题 I have an element to replace and the html text is in varaiable h The first call to this works perfectly. But the second call does not. var newElement; var h="<div>a</div>"; newElement = angular.element(h); $compile(newElement[0])($scope); angular.element($element[0]).replaceWith(newElement[0]); 回答1: I think the mistake here is you have compiled the html template but u havent used it . var newElement; var h="<div>a</div>"; newElement = angular.element(h); angular.element($element[0])

How to transfer data between controllers

感情迁移 提交于 2019-12-08 13:17:16
问题 I am trying to transfer data between controllers. So this is my first controller that fetches data first when page loads using http- function GetController($scope, $http) { $http.defaults.useXDomain = true; $http({ method: 'POST', url: serviceUrl + '/GetProductsByCategoryOrName', headers: { 'Authorization': apiKey }, data: { "query": "grocery", "categoryId": "976759", "pageIndex": 0, "sortDirection": "asc" } }).then(function successCallback(response) { $scope.products = response.data; }).then

How to update angularjs $scope from $.get jquery?

情到浓时终转凉″ 提交于 2019-12-08 11:47:59
问题 I am trying to use the following code and use $scope : var scopes = "https://www.googleapis.com/auth/contacts.readonly"; setTimeout(authorize(), 20); function authorize() { gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthorization); } invitePeersController.gmailContacts = []; function handleAuthorization(authorizationResult) { if (authorizationResult && !authorizationResult.error) { $.get("https://www.google.com/m8/feeds/contacts/default/thin?alt=json

ui-grid custom directive height not getting updated when i change the data

我的未来我决定 提交于 2019-12-08 11:33:42
问题 I have a UI-grid Custom Directive and I am changing the height of grid with a condition that if it has more than 10 rows I am fixing the height, this is the following code scope.gridOptions.data = scope.data; if (scope.data.length > 10) { scope.gridOptions.minRowsToShow = 10; } else { scope.gridOptions.minRowsToShow = scope.data.length; } scope.gridOptions.virtualizationThreshold =scope.gridOptions.minRowsToShow; by default its working fine but when I change the data the height is not

AngularJS share asynchronous service data between controllers

非 Y 不嫁゛ 提交于 2019-12-08 10:56:25
I know this issue has been asked several times in stackoverflow, but I couldn't find a proper answer. What I need to achieve is to be able to initiate some asynchronous call in one controller and when the result returns update the $scope in some other controller. I understand that I should use a shared service that actually does the $http stuff, but I can't manage to update the other controller scope. Here is my code: View <div class="screens" ng-controller="framesController"> <div class="scroller scroll-pane" frames-scroll-pane> <div class="overview"> {{frames}} </div> </div> </div> Service