Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 25d4e5cca4 | |||
| c67112563f | |||
| 2b2ec26a75 | |||
| 41f90e5fb0 | |||
| a85c591d36 |
@@ -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
@@ -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
@@ -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
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user