<a href='https://github.com/angular/angular.js/edit/v1.7.x/docs/content/guide/migration.ngdoc?message=docs(guide%2FMigrating from Previous Versions)%3A%20describe%20your%20change...' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit"> </i>Improve this Doc</a>
<h1 id="migrating-an-app-to-a-newer-version">Migrating an App to a newer version</h1>
<p>Minor version releases in AngularJS introduce several breaking changes that may require changes to your
application's source code; for instance from 1.0 to 1.2 and from 1.2 to 1.3.</p>
<p>Although we try to avoid breaking changes, there are some cases where it is unavoidable:</p>
<ul>
<li>AngularJS has undergone thorough security reviews to make applications safer by default,
which drives many of these changes.</li>
<li>Several new features, especially animations, would not be possible without a few changes.</li>
<li>Finally, some outstanding bugs were best fixed by changing an existing API.</li>
</ul>
<h2 id="migrating-from-1-6-to-1-7">Migrating from 1.6 to 1.7</h2>
<p>AngularJS 1.7 contains bug fixes and features to AngularJS core and its external modules, some of
which contain breaking changes. However, most of these address internal behavior and not APIs, and
should not affect many applications.
Additionally, we have removed some long-deprecated modules and APIs.</p>
<p>The most notable changes are:</p>
<ul>
<li><p>$resource has now support for request and requestError interceptors</p>
</li>
<li><p>Several deprecated features have been removed:</p>
<ul>
<li>the <code>$controllerProvider.allowGlobals()</code> flag</li>
<li>the <code>$compileProvider.preAssignBindingsEnabled()</code> flag</li>
<li>the <code>angular.lowercase</code> and <code>angular.uppercase</code> methods</li>
<li>the <code>$cookieStore</code> service from the <code>ngCookies</code> module</li>
<li>the <code>ngClick</code> override directive and corresponding services from the <code>ngTouch</code> module</li>
<li>the complete <code>ngScenario</code> module</li>
</ul>
</li>
</ul>
<p>Please note that feature development (without breaking changes) has happened in parallel on the
1.6.x branch, so 1.7 doesn't contain many new features, but you may still benefit from those features
that were added (with possible BCs), bugfixes, and a few smaller performance improvements.</p>
<p><br />
Below is the full list of breaking changes:</p>
<p><br />
<a name="migrate1.6to1.7-ng-directives"></a></p>
<h3 id="core-_directives_">Core: <em>Directives</em></h3>
<p><a name="migrate1.6to1.7-ng-directives-form"></a></p>
<h4 id="-form-"><strong>form</strong></h4>
<p><strong>Due to <a href="https://github.com/angular/angular.js/commit/223de59e988dc0cc8b4ec3a045b7c0735eba1c77">223de5</a></strong>,
forms will now set $submitted on child forms when they are submitted.
For example:</p>
<pre><code><form name="parentform" ng-submit="$ctrl.submit()">
<ng-form name="childform">
<input type="text" name="input" ng-model="my.model" />
</ng-form>
<input type="submit" />
</form>
</code></pre>
<p>Submitting this form will set $submitted on "parentform" and "childform".
Previously, it was only set on "parentform".</p>
<p>This change was introduced because mixing form and ngForm does not create
logically separate forms, but rather something like input groups.
Therefore, child forms should inherit the submission state from their parent form.</p>
<h4 id="-input-radio-and-input-checkbox-"><strong>input[radio]</strong> and <strong>input[checkbox]</strong></h4>
<p><strong>Due to <a href="https://github.com/angular/angular.js/commit/656c8fa8f23b1277cc5c214c4d0237f3393afa1e">656c8f</a></strong>,
<code>input[radio]</code> and <code>input[checkbox]</code> now listen to the "change" event instead of the "click" event.
Most apps should not be affected, as "change" is automatically fired by browsers after "click"
happens.</p>
<p>Two scenarios might need migration:</p>
<ul>
<li>Custom click events:</li>
</ul>
<p>Before this change, custom click event listeners on radio / checkbox would be called after the
input element and <code>ngModel</code> had been updated, unless they were specifically registered before
the built-in click handlers.
After this change, they are called before the input is updated, and can call event.preventDefault()
to prevent the input from updating.</p>
<p>If an app uses a click event listener that expects ngModel to be updated when it is called, it now
needs to register a change event listener instead.</p>
<ul>
<li>Triggering click events:</li>
</ul>
<p>Conventional trigger functions:</p>
<p>The change event might not be fired when the input element is not attached to the document. This
can happen in <strong>tests</strong> that compile input elements and
trigger click events on them. Depending on the browser (Chrome and Safari) and the trigger method,
the change event will not be fired when the input isn't attached to the document.</p>
<p>Before:</p>
<pre><code class="lang-js">it('should update the model', inject(function($compile, $rootScope) {
var inputElm = $compile('<input type="checkbox" ng-model="checkbox" />')($rootScope);
inputElm[0].click(); // Or different trigger mechanisms, such as jQuery.trigger()
expect($rootScope.checkbox).toBe(true);
});
</code></pre>
<p>With this patch, <code>$rootScope.checkbox</code> might not be true, because the click event
hasn't triggered the change event. To make the test, work append the inputElm to the app's
<code>$rootElement</code>, and the <code>$rootElement</code> to the <code>$document</code>.</p>
<p>After:</p>
<pre><code class="lang-js">it('should update the model', inject(function($compile, $rootScope, $rootElement, $document) {
var inputElm = $compile('<input type="checkbox" ng-model="checkbox" />')($rootScope);
$rootElement.append(inputElm);
$document.append($rootElement);
inputElm[0].click(); // Or different trigger mechanisms, such as jQuery.trigger()
expect($rootScope.checkbox).toBe(true);
});
</code></pre>
<h4 id="-input-number-"><strong>input[number]</strong></h4>
<p><strong>Due to <a href="https://github.com/angular/angular.js/commit/aa3f951330ec7b10b43ea884d9b5754e296770ec">aa3f95</a></strong>,
<code>input[type=number]</code> with <code>ngModel</code> now validates the input for the <code>max</code>/<code>min</code> restriction against
the <code>ngModelController.$viewValue</code> instead of against the <code>ngModelController.$modelValue</code>.</p>
<p>This affects apps that use <code>$parsers</code> or <code>$formatters</code> to transform the input / model value.</p>
<p>If you rely on the $modelValue validation, you can overwrite the <code>min</code>/<code>max</code> validator from a custom directive, as seen in the following example directive definition object:</p>
<pre><code>{
restrict: 'A',
require: 'ngModel',
link: function(scope, element, attrs, ctrl) {
var maxValidator = ctrl.$validators.max;
ctrk.$validators.max = function(modelValue, viewValue) {
return maxValidator(modelValue, modelValue);
};
}
}
</code></pre>
<h4 id="-ngmodel-input-"><strong>ngModel, input</strong></h4>
<p><strong>Due to <a href="https://github.com/angular/angular.js/commit/74b04c9403af4fc7df5b6420f22c9f45a3e84140">74b04c</a></strong>,
<em>Custom</em> parsers that fail to parse on input types "email", "url", "number", "date", "month",
"time", "datetime-local", "week", no longer set <code>ngModelController.$error[inputType]</code>, and
the <code>ng-invalid-[inputType]</code> class. Also, custom parsers on input type "range" do no
longer set <code>ngModelController.$error
没有合适的资源?快使用搜索试试~ 我知道了~
angular-1.7.0.zip
共2000个文件
html:1286个
js:464个
json:201个
需积分: 0 0 下载量 49 浏览量
2024-04-25
12:49:31
上传
评论
收藏 7.13MB ZIP 举报
温馨提示
Angular.js 各个版本,免费下载 如果不能下载,关注我,评论区联系我
资源推荐
资源详情
资源评论
收起资源包目录
angular-1.7.0.zip (2000个子文件)
bootstrap.css 118KB
bootstrap.min.css 98KB
docs.css 19KB
angular-topnav.css 4KB
doc_widgets.css 3KB
prettify.css 2KB
prettify-theme.css 1KB
styles.css 1KB
animations.css 684B
animations.css 599B
animations.css 591B
animations.css 591B
animations.css 589B
animations.css 569B
animations.css 540B
animations.css 540B
animations.css 492B
animations.css 458B
style.css 393B
style.css 393B
style.css 379B
animations.css 343B
style.css 303B
style.css 299B
style.css 281B
style.css 268B
style.css 236B
style.css 230B
animations.css 224B
animations.css 224B
style.css 196B
animations.css 179B
style.css 137B
style.css 136B
style.css 125B
style.css 103B
style.css 98B
style.css 97B
style.css 94B
style.css 74B
app.css 60B
style.css 47B
style.css 47B
style.css 27B
style.css 24B
animations.css 0B
migration.html 182KB
ng.html 66KB
$compile.html 62KB
$httpBackend.html 52KB
directive.html 51KB
component-router.html 47KB
$http.html 45KB
$sce.html 44KB
$location.html 41KB
$rootScope.Scope.html 40KB
ngModel.NgModelController.html 39KB
ngAnimate.html 34KB
$animate.html 33KB
orderBy.html 30KB
forms.html 28KB
$httpBackend.html 27KB
scope.html 26KB
component.html 24KB
$resource.html 24KB
animations.html 24KB
i18n.html 24KB
ngRepeat.html 24KB
compiler.html 23KB
unit-testing.html 22KB
concepts.html 22KB
ngModelOptions.html 22KB
step_14.html 22KB
accessibility.html 21KB
directive.html 20KB
decorators.html 20KB
$q.html 20KB
select.html 20KB
$compileProvider.html 20KB
$provide.html 19KB
faq.html 19KB
expression.html 19KB
step_09.html 18KB
ngOptions.html 18KB
providers.html 18KB
$location.html 18KB
angular.Module.html 17KB
controller.html 17KB
ngMessages.html 16KB
$route.html 16KB
di.html 15KB
tutorial.html 15KB
$injector.html 15KB
$animateCss.html 14KB
inprog.html 14KB
$routeProvider.html 14KB
step_02.html 14KB
external-resources.html 14KB
step_07.html 14KB
step_04.html 13KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
段子手-168
- 粉丝: 2118
- 资源: 2661
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功