angularjs-scope

Getting value of ng-change field in my angularjs controller

霸气de小男生 提交于 2019-12-11 02:24:22
问题 I have this line in my view: <input placeholder="Search" type="text" ng-change="searchChange()" ng-model="mySearch" ng-model-options="{debounce: 1000}"> And then inside my controller I have: angular.module('app.controllers', []) .controller('listViewCtrl', ['$scope', '$stateParams', '$http', function ($scope, $stateParams, $http) { $http.get('http://www.domain.co.uk/api/search.php'). then(function(response) { $scope.food = response.data; }); $scope.searchChange = function() { console.log(

Scope inheritance for angular directives

我与影子孤独终老i 提交于 2019-12-11 02:18:33
问题 I've created a tab control using angular directives. It is consist of tab , tab-item directives with new scope and tab-item-header , tab-item-body directives for which scope is not declared. If I understand correctly these directives use scope of tab-item directive because they are placed inside it. But when I try to get in markup property index which is declared inside tab-item scope it is undefined. app.directive('tabItemHeader', function(){ return { require: '^tabItem', transclude: true,

AngularJS Scopes and Deferreds

人盡茶涼 提交于 2019-12-11 02:05:41
问题 I have a service that does something hard and returns a promise: .factory('myService', function($q) { return { doSomethingHard: function() { var deferred = $q.defer(); setTimeout(function() { deferred.resolve("I'm done!"); }, 1000); return deferred.promise; } }; }) I have a controller that adds a function to the scope using that service: .controller('MyCtrl', function($scope, myService) { $scope.doSomething = function() { var promise = myService.doSomethingHard(); promise.then(function(result

AngularJS templateUrl vs template - isolate scope

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 01:28:52
问题 I have the following directive: offerListSorters.directive('offersSorter', ['myState', '$templateCache', function (myState, $templateCache){ return { scope: {}, controller: function($scope, $element, $attrs, $transclude) { [...] }, restrict: 'E', //templateUrl: 'partials/offersSorterDirective.html', template: $templateCache.get('partials/offersSorterDirective.html'), replace: true, transclude: true }; }]); And I use Karma + Jasmine to test this code and it works. But now if I switch to the

Difference between $http.get , $http.post ,$http.put , $http.delete $http.head and $http.jsonp [closed]

非 Y 不嫁゛ 提交于 2019-12-11 01:25:51
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I am new to angular js and web development. Please help me. Today i read about $http in angular js but i am only aware about the get and post methods . Can Please anyone explain ,me what is the Difference between $http.get , $http.post ,$http.put , $http.delete $http.head and

how to test $http call in angular js?

一个人想着一个人 提交于 2019-12-11 00:53:57
问题 I am trying to test my $http request using karma and jasmine.I make one controller and inject a service .In service I call $http service.I need to test that service how I will test this service this is my controller. angular.module('app',[]).controller('first',function($scope,data){ $scope.name='test'; data.getData().then(function(data){ console.log(data); }) }).factory('data',function($http){ return{ getData:getData } function getData(){ return $http.get('data.json').success(successCall)

Executing a scope bound function with parameters [duplicate]

烈酒焚心 提交于 2019-12-11 00:48:05
问题 This question already has answers here : How to call a method defined in an AngularJS directive? (13 answers) Closed 5 years ago . If I have a function like this in a directive: scope: { loadChildren: "&" }, How can I call this from my controller and pass parameters? $scope.loadChildren(param1, param2); My directive executes the function I pass it but I don't see any parameters. Is there any way to pass them like this? EDIT re: rodyhaddad's answer rodyhaddad points the way and gives the

angular how to define multiple controllers

好久不见. 提交于 2019-12-11 00:46:53
问题 i have code like this angular.module('mywidget', ['$scope']).controller('TestController', testController); I want to add another controller to it ..say ...controller("Test2Controller",Test2Controller) just wanted to know how we can achieve this ? 回答1: You can var myApp = angular.module('mywidget', ['$scope']); myApp.controller('TestController', testController); myApp.controller('Test2Controller', test2Controller); 来源: https://stackoverflow.com/questions/18100755/angular-how-to-define-multiple

Angular retrieve specific data into $scope variable is not working

孤者浪人 提交于 2019-12-11 00:09:24
问题 I initialize here $scope.statuses = []; Then if I simply set the data from $http.get to the $scope variable, that "works" but I need to filter it down more. $scope.statuses = result.data.Devices; console.log($scope.statuses); That returns the array of data like this in dev tools console output 0: Object $$hashKey : "object:5" Aid : "oAAABTUAAg==" DKiIndex : "DKi00000002" DefaultPayload : "C:\ProgramData\" DeviceId : "00022B9A000000010001" DeviceStatus : 3 ManifestIdList : Array[3]

Angular.js - ngModel value is undefined when ng-pattern is set in directive

只谈情不闲聊 提交于 2019-12-10 23:47:20
问题 something similar may have been answered (ng-pattern + ng-change) but all responses were unable to fix this issue. I have two imbricated directives for creating a form input, a parent directive to control name, label, validator etc. and a child directive to set pattern and input type specific stuff. However, when setting a pattern, the value on my model is set to undefined when ng-pattern return false. Directives: <input-wrapper ng-model="vm.customer.phone" name="phone" label="Phone number">