Tim van der Heijden | 16 Jan 14:18 2015
Picon

different results for transformRequest function in $http when doing a form based http POST. 'succes' function versus 'then'

Hi All,

 I posted this question on stackOverflow:
http://stackoverflow.com/questions/27900570/angularjs-http-post-request-different-results-with-then-and-success

Basically it comes down to this: (I use angular 1.2.26)
  1. I invoke an HTTP service with a application/x-www-form-urlencoded header
  2. I handle the result with the success handler on my $http promise. It works, great!
  3. I want to use the 'then' function instead of 'succes', so I change the code into working with 'then'
  4. Now my server impl crashes when I invoke the same service, reason: my transformRequest function returns a totally different result.
Anybody knows why transformRequest can return different results when using 'then' and 'succes' ?

Thanks in advance,

Tim

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Tob | 16 Jan 10:10 2015
Picon

Inherit directive

Hi all,

I would like to inherit a directive ?

How can I do it ?

Thanks for your advices

Jonathan Price | 16 Jan 09:21 2015
Picon

ng-if not cloaking code as hoped

The people using this code have a pretty slow internet connection (like 900kbps down), and it's wreaking a little havoc on some seemingly simple thing.

I've got something like this in my page:

<div ng-if="loaded.loaded" ng-controller="NoteCategorySectionController">
                <div xmd-note-edit note-type="{{noteType.NOTETYPE}}"></div>
</div>
<div ng-if="loaded.loaded">
                <div ng-include="'assets/partials/noteTypeEditLink.html'"></div>
</div>


The first directive is a pretty simple template directive.  Just used to encapsulate a table.
The ng-include is something like this:
<a class="body" ng-click="exposeNoteEdit(noteType)"
    value="test">Add {{noteType.ABBREVIATION === '' ? noteType.NOTETYPE : noteType.ABBREVIATION}}</a>


The xmd-note-edit directive never flashes code.  Ever.  The ng-include bit flashes code 80% of the time.  I can't for the life of me get it to disappear consistently.

The bit that's in the ng-include used to be directly coded into the page.  I thought maybe the html was loading before angular was loaded, thus the constant code flash.  So, I figured putting it in an ng-include would ensure that didn't happen.  Apparently that wasn't the problem.

Also of note, this is NOT an entire angular app.  I'm just including angular on a few pages for some two-way binding.

All suggestions appreciated.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
spamwax | 16 Jan 05:37 2015
Picon

How does controller know it should use a mocked dependency in place of original one?

Hello,

The dependency injection in tests is confusing to me.
Specifically in chapter 5 of tutorial, I can see that $httpBackend is configured to provide a fake response:
$httpBackend = _$httpBackend_;
$httpBackend
.expectGET('phones/phones.json').
    respond
([{name: 'Nexus S'}, {name: 'Motorola DROID'}]);

But I can't see why the controller wants to use this newly defined dependency instead of the original $http introduced in PhoneListCtrl definition.

In the same code snippet, if the controller was initialized with something like this:
scope = $rootScope.$new();
ctrl
= $controller('PhoneListCtrl', {
                                     $scope
: scope,
                                     $http
: $httpBackend});


I could understand that we are overriding the dependency so when the controller wants to access $http, it will use our mocked one.
But given that't not the case:
scope = $rootScope.$new();
ctrl
= $controller('PhoneListCtrl', {$scope: scope});
And only the scope is passed to $controller and I can't see anything that would link the $httpBackend to the controller.

I am just confused how the controller know about the new mocked service/dependency.

Any hint is appreciated.

Best,

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Stephen Nancekivell | 16 Jan 03:22 2015
Picon

Why do my unit tests run faster when Im not connected to the internet?

Im having slowness problems with my unit tests, using karma. They take about 20seconds.

I've tried debugging with chrome but cant see anything that would explain it.

When I disconnect my computer from the internet my tests run in 3 seconds. It seems like my angular app is hitting the network, which I cant see. I've tried basic logging, intercepting network traffic, tcpdump'ing.

Has anyone come across this or have any ideas on how I can debug this further.

Thanks.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Anas Raza Firdousi | 16 Jan 02:22 2015
Picon

Re: Re: How can i call two controllers on one div?

When you do this, be sure of the fact that $emit/$broadcast wont work from one controller to the other because there is no parent / child relationship.

One hacky-way, in such situations is to do $scope.$parent.$broadcast(...) kind of thing. You may have guess that the controller emitting the event can also listen to it since both the controller have a common parent :)

On Thursday, November 29, 2012 at 12:19:48 PM UTC-8, Pete Bacon Darwin wrote:
You can create any number of directives that create "directive controllers" and apply them all to the same element.


Pete


On 29 November 2012 16:35, Jim Hoskins <j... <at> jimhoskins.com> wrote:
Why exactly do you need this? Are there places you would use ctrl1 OR ctrl2 and not both? Nesting one of the controllers in the other should work, unless you are doing some very specific things in which case it may not.

You could, and I don't know if this is the best way to go, write a 3rd controller, that is composed of the other two. Basically instantiate ctrl1 and ctrl2 from ctrl3, passing through the $scope, $element, $attrs, and $transclude. 

Heres a plunker of it http://plnkr.co/edit/79GOUe?p=preview


On Thursday, November 29, 2012 10:10:22 AM UTC-5, Nina wrote:
I need call two controllers (ctrl1, ctrl2) on the same div(id="div1"), if its possible, how can i do it?

<div id="div1" ng-controller="ctrl1">
...
</div>

thx all

Nina

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang... <at> googlegroups.com.
To unsubscribe from this group, send email to angular+u... <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
 
 

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Michael Laird | 15 Jan 22:58 2015
Picon

ng-messages, form validation and utf-8

I have tried to check whether ng-messages supports utf-8 characters in validation logic at this tutorial:    http://www.tutorialsavvy.com/2014/09/angularjs-message-module.html

The HTML includes <meta utf-8> but when I enter European character email addresses in the email box, I get an error - not valid email address.  I'm entering things like:
érmi <at> aseña.com

Did the tutorial writer make some error (the code is in the tutorial), or does Angularjs client validation and messages not support utf-8 character entry?

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Dev | 15 Jan 20:50 2015
Picon

JQuery date picker is not updating based on ng model

Hi,
 
    I have created a JQuery calendar control directive andinjected my ngModel.
 
       My model is getting updating with my calendar selected value,  but datepicker is not updating with changed model value.
 
      I have written like this:
 


           
 restrict: 'EA',

            replace
: true,
           
           
require: 'ngModel',
           
template: '<div><input class="datepicker --input" type="text" placeholder="mm/dd/yyyy"><button id="calender" class="calendar-button"></button></div>',
            link
: function ($scope, $elem, $attrs, ngModelCtrl) {
               -------
 

 $
('.datepicker--input').DatePicker({
                       
                       forbiddendays
: {
                               range: [],
                                days
: List.value
                       
},
                           minDate: 0,
                            usedatemask
: true,
                            onSelect
: function (dateText) { updateModel(dateText);
                         
                               
       
}
 
 var updateModel = function (dateText) {
                 $scope
.$apply(function () {
                 
ngModelCtrl.$setViewValue(dateText);
         
       
});
     
};

 
 
Did I miss anything here?

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Mohan Radhakrishnan | 15 Jan 18:33 2015
Picon

Extending controllers


Hi,
        I have already read some old posts like this.
         https://groups.google.com/forum/#!searchin/angular/extend$20controller/angular/qqncwxdcVgw/VrSktAbxFLMJ

         The code in this post loosk useful. Ours is a large codebase and there is a good domain model visible in the functionality. I have decided to use a JavaScript functional pattern for the domain model. But even the controllers can extend each other. Let us assume that
there are two types of enrollments and one could reuse logic from the the base enrollment controller. Is the controller extension method in the referred post recommended ?

What is the approach to extend services ?
 
Thanks,
Mohan

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Shailendra Saxena | 15 Jan 16:27 2015
Picon

Passing Value to a Angular Controller from MVC Controller Action

Passing Value to a Angular Controller from MVC Controller Action

Hi ,

I have a Angular MVC Application my Angular controller code is like below.

app.controller('SearchController', ['$scope','$http',function ($scope, $http) {
    $scope.sessionGuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
    $scope.searchValue = "";
    $scope.stockNumber = "";

    $scope.searchRequest = {
        Criteria: [],
        resultsTabIndex: 0,
        orderBy: "sortbypopularity",
        value:"mut" //Added
     
    };

I have a view Search.Html Which display the data on the basis of searchRequest object which is defined in Controller above.

Now i have a requirement that i Need to show this view from MVC controller.

Do you have any idea how can i pass value to controller which is required by the search request object  so that i can show the view with the data.

Thanks

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Shishir Roy | 15 Jan 14:40 2015
Picon

Generating a angular model at runtime and make it as a two way binding

Hi,


My requirement is like : 

I have a list of input control and each list is linked to model which i wanted to generated at runtime.
Based on the model generated at runtime it will have same number of input control. 

Also along with that if any input control data is modified then i want that modified data.

Please suggest me.

Thank you,
Shishir

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Gmane