Compare commits

..

5 Commits

Author SHA1 Message Date
Georgios Kalpakas 25d4e5cca4 fix($http): pass event object to eventHandlers/uploadEventHandlers
Fixes #14436
2016-04-15 14:09:39 +01:00
Peter Bacon Darwin c67112563f revert: refactor($compile): move setting of controller data to single location
Reverted from commit 21d148aedc since it caused
the Angular Material tabs directive to fail.
2016-04-15 14:09:05 +01:00
Jannick Fahlbusch 2b2ec26a75 chore(docsApp): open plnkr.co with HTTPS
Plnkr should be opened via HTTPS instead of HTTP to supress warnings about an insecure connection

Closes #14445
2016-04-15 14:55:13 +02:00
cloverharvest 41f90e5fb0 docs($http): fix a typo (his --> this)
Closes #14430
2016-04-15 01:25:09 +03:00
Adam Demuri a85c591d36 docs(component): document 'require' in angular.component
Closes #14429
2016-04-15 01:12:43 +03:00
4 changed files with 28 additions and 17 deletions
+1 -1
View File
@@ -153,7 +153,7 @@ angular.module('examples', [])
postData.description = ctrl.example.name;
formPostData('http://plnkr.co/edit/?p=preview', newWindow, postData);
formPostData('https://plnkr.co/edit/?p=preview', newWindow, postData);
});
};
+13 -7
View File
@@ -1047,6 +1047,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
* See {@link ng.$compile#-bindtocontroller- `bindToController`}.
* - `transclude` `{boolean=}` whether {@link $compile#transclusion content transclusion} is enabled.
* Disabled by default.
* - `require` - `{Object<string, string>=}` - requires the controllers of other directives and binds them to
* this component's controller. The object keys specify the property names under which the required
* controllers (object values) will be bound. See {@link ng.$compile#-require- `require`}.
* - `$...` additional properties to attach to the directive factory function and the controller
* constructor function. (This is used by the component router to annotate)
*
@@ -2434,13 +2437,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}
}
// Initialize controllers
// Initialize bindToController bindings
for (var name in elementControllers) {
var controllerDirective = controllerDirectives[name];
var controller = elementControllers[name];
var bindings = controllerDirective.$$bindings.bindToController;
// Initialize bindToController bindings
if (controller.identifier && bindings) {
controller.bindingInfo =
initializeDirectiveBindings(controllerScope, attrs, controller.instance, bindings, controllerDirective);
@@ -2453,14 +2455,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
// If the controller constructor has a return value, overwrite the instance
// from setupControllers
controller.instance = controllerResult;
$element.data('$' + controllerDirective.name + 'Controller', controllerResult);
controller.bindingInfo.removeWatches && controller.bindingInfo.removeWatches();
controller.bindingInfo =
initializeDirectiveBindings(controllerScope, attrs, controller.instance, bindings, controllerDirective);
}
// Store controllers on the $element data
// For transclude comment nodes this will be a noop and will be done at transclusion time
$element.data('$' + controllerDirective.name + 'Controller', controllerResult);
}
// Bind the required controllers to the controller, if `require` is an object and `bindToController` is truthy
@@ -2627,7 +2626,14 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
controller = attrs[directive.name];
}
elementControllers[directive.name] = $controller(controller, locals, true, directive.controllerAs);
var controllerInstance = $controller(controller, locals, true, directive.controllerAs);
// For directives with element transclusion the element is a comment.
// In this case .data will not attach any data.
// Instead, we save the controllers for the element in a local hash and attach to .data
// later, once we have the actual element.
elementControllers[directive.name] = controllerInstance;
$element.data('$' + directive.name + 'Controller', controllerInstance.instance);
}
return elementControllers;
}
+9 -5
View File
@@ -555,7 +555,7 @@ function $HttpProvider() {
* That means changes to the properties of `data` are not local to the transform function (since Javascript passes objects by reference).
* For example, when calling `$http.get(url, $scope.myObject)`, modifications to the object's properties in a transformRequest
* function will be reflected on the scope and in any templates where the object is data-bound.
* To prevent his, transform functions should have no side-effects.
* To prevent this, transform functions should have no side-effects.
* If you need to modify properties, it is recommended to make a copy of the data, or create new object to return.
* </div>
*
@@ -1276,13 +1276,17 @@ function $HttpProvider() {
if (eventHandlers) {
var applyHandlers = {};
forEach(eventHandlers, function(eventHandler, key) {
applyHandlers[key] = function() {
applyHandlers[key] = function(event) {
if (useApplyAsync) {
$rootScope.$applyAsync(eventHandler);
$rootScope.$applyAsync(callEventHandler);
} else if ($rootScope.$$phase) {
eventHandler();
callEventHandler();
} else {
$rootScope.$apply(eventHandler);
$rootScope.$apply(callEventHandler);
}
function callEventHandler() {
eventHandler(event);
}
};
});
+5 -4
View File
@@ -1066,14 +1066,15 @@ describe('$http', function() {
expect(mockXHR.$$events.progress).toEqual(jasmine.any(Function));
expect(mockXHR.upload.$$events.progress).toEqual(jasmine.any(Function));
var eventObj = {};
spyOn($rootScope, '$digest');
mockXHR.$$events.progress();
expect(progressFn).toHaveBeenCalledOnce();
mockXHR.$$events.progress(eventObj);
expect(progressFn).toHaveBeenCalledOnceWith(eventObj);
expect($rootScope.$digest).toHaveBeenCalledTimes(1);
mockXHR.upload.$$events.progress();
expect(uploadProgressFn).toHaveBeenCalledOnce();
mockXHR.upload.$$events.progress(eventObj);
expect(uploadProgressFn).toHaveBeenCalledOnceWith(eventObj);
expect($rootScope.$digest).toHaveBeenCalledTimes(2);
});
});