packaged angular-resource
This repo is for distribution on npm
and bower
. The source for this module is in the
main AngularJS repo.
Please file issues and pull requests against that repo.
Install
You can install this package either with npm
or with bower
.
npm
npm install angular-resource
Then add ngResource
as a dependency for your app:
angular.module('myApp', [require('angular-resource')]);
bower
bower install angular-resource
Add a <script>
to your index.html
:
<script src="/bower_components/angular-resource/angular-resource.js"></script>
Then add ngResource
as a dependency for your app:
angular.module('myApp', ['ngResource']);
Documentation
Documentation is available on the
AngularJS docs site.
License
The MIT License
Copyright (c) 2010-2015 Google, Inc. http://angularjs.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
1.4.0-beta.5 karmic-stabilization (2015-02-24)
Bug Fixes
- $http: properly access request headers with mixed case
(5da1256f,
#10881, #10883)
- input: create max and/or min validator regardless of initial value
(c211e7a5,
#10307, #10327)
- ngAria: correctly set "checked" attr for checkboxes and radios
(d6eba217,
#10389, #10212)
- ngModel: fix issues when parserName is same as validator key
(056a3170,
#10698, #10850, #11046)
- ngOptions: ngModel is optional
(ef894c87)
- ngSanitize: Do not ignore white-listed svg camelCased attributes
(46b80654,
#10779, #10990, #11124)
- select: remove unknown option when model is undefined and empty option is available
(30b48132,
#11078, #11092)
- templateRequest: avoid throwing syntax error in Android 2.3
(f6272333,
#11089, #11051, #11088)
Features
-
CommonJS: - angular modules are now packaged for npm with helpful exports
-
limitTo: extend the filter to take a beginning index argument
(aaae3cc4,
#5355, #10899)
-
ngMessages: provide support for dynamic message resolution
(c9a4421f,
#10036, #9338)
-
ngOptions: add support for disabling an option
(da9eac86,
#638, #11017)
Performance Improvements
- $compile:
- replace forEach(controller) with plain loops
(5b522867,
#11084)
- avoid .data when fetching required controllers
(fa0aa839)
- ngOptions: only watch labels if a display expression is specified
(51faaffd)
Breaking Changes
The ngMessagesInclude
attribute is now its own directive and that must
be placed as a child element within the element with the ngMessages
directive. (Keep in mind that the former behavior of the
ngMessageInclude attribute was that all included ngMessage template
code was placed at the bottom of the element containing the
ngMessages directive; therefore to make this behave in the same way,
place the element containing the ngMessagesInclude directive at the
end of the container containing the ngMessages directive).
<!-- AngularJS 1.3.x -->
<div ng-messages="model.$error" ng-messages-include="remote.html">
<div ng-message="required">Your message is required</div>
</div>
<!-- AngularJS 1.4.x -->
<div ng-messages="model.$error">
<div ng-message="required">Your message is required</div>
<div ng-messages-include="remote.html"></div>
</div>
it is no longer possible to use interpolation inside the ngMessages
attribute expression. This technique
is generally not recommended, and can easily break when a directive implementation changes. In cases
where a simple expression is not possible, you can delegate accessing the object to a function:
<div ng-messages="ctrl.form['field_{{$index}}'].$error">...</div>
would become
<div ng-messages="ctrl.getMessages($index)">...</div>
where ctrl.getMessages()
ctrl.getMessages = function($index) {
return ctrl.form['field_' + $index].$error;
}
transformRequest
functions can no longer modify request headers.
Before this commit transformRequest
could modify request headers, ex.:
function requestTransform(data, headers) {
headers = angular.extend(headers(), {
'X-MY_HEADER': 'abcd'
});
}
return angular.toJson(data);
}
This behavior was unintended and undocumented, so the change should affect very few applications. If one
needs to dynamically add / remove headers it should be done in a header function, for example:
$http.get(url, {
headers: {
'X-MY_HEADER': function(config) {
return 'abcd'; //you've got access to a request config object to specify header value dynamically
}
}
})
<a name="1.3.14"></a>