最后
为了帮助大家更好的了解前端,特别整理了《前端工程师面试手册》电子稿文件。
开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】
rendered - a promise that is resolved when a modal is rendered.
In addition the scope associated with modal’s content is augmented with 2 methods:
$close(result)
$dismiss(reason)
Those methods make it easy to close a modal window without a need to create a dedicated controller.
If the s c o p e i s d e s t r o y e d v i a u n e x p e c t e d m e c h a n i s m , s u c h a s i t b e i n g p a s s e d i n t h e m o d a l o p t i o n s a n d a scope is destroyed via unexpected mechanism, such as it being passed in the modal options and a scope is destroyed via unexpected mechanism, such as it being passed in the modal options and a route/$state transition occurs,
the modal will be dismissed with the value $uibUnscheduledDestruction.
Finally, a modal.closing event is broadcast to the modal scope before the modal closes. If the listener calls preventDefault on the event,
then the modal will remain open. The c l o s e a n d close and close and dismiss methods return true if the event was allowed.
The event itself includes a parameter for the result/reason and a boolean parameter that indicates whether the modal is being closed (true) or dismissed.
译文如下:
$modal是一个可以迅速创建模态窗口的服务,创建部分页,控制器,并关联他们。
$modal仅有一个方法open(options),可以使用的选项如下:
templateUrl:模态窗口的地址
template:用于显示html标签
scope:一个作用域为模态的内容使用(事实上, m o d a l 会创建一个当前作用域的子作用域)默认为 modal会创建一个当前作用域的子作用域)默认为 modal会创建一个当前作用域的子作用域)默认为rootScope
controller:为 m o d a l 指定的控制器,初始化 modal指定的控制器,初始化 modal指定的控制器,初始化scope,该控制器可用$modalInstance注入
resolve:定义一个成员并将他传递给$modal指定的控制器,相当于routes的一个reslove属性,如果需要传递一个objec对象,需要使用angular.copy()
backdrop:控制背景,允许的值:true(默认),false(无背景),“static” - 背景是存在的,但点击模态窗口之外时,模态窗口不关闭
keyboard:当按下Esc时,模态对话框是否关闭,默认为ture
windowClass:指定一个class并被添加到模态窗口中
open方法返回一个模态实例,该实例有如下属性
close(result):关闭模态窗口并传递一个结果
dismiss(reason):撤销模态方法并传递一个原因
result:一个契约,当模态窗口被关闭或撤销时传递
opened:一个契约,当模态窗口打开并且加载完内容时传递的变量
另外, m o d a l I n s t a n c e 扩展了两个方法 modalInstance扩展了两个方法 modalInstance扩展了两个方法close(result)、$dismiss(reason),这些方法很容易关闭窗口并且不需要额外的控制器
实战:
在app.js中需要加入依赖ui.bootstrap,需要在index.html中引入ui-bootstrap-tpls-0.7.0.js。
以下为html代码:
<div ng-controller="ModalDemoCtrl">
<span style="white-space:pre"> </span><script type="text/ng-template" id="myModalContent.html">
<span style="white-space:pre"> </span><div class="modal-header">
<span style="white-space:pre"> </span><h3 class="modal-title">I'm a modal!</h3>
<span style="white-space:pre"> </span></div>
<span style="white-space:pre"> </span><div class="modal-body">
<span style="white-space:pre"> </span><ul>
<span style="white-space:pre"> </span> <li ng-repeat="item in items">
<span style="white-space:pre"> </span> <a href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item }}</a>
</li>
</ul>
Selected: <b>{{ selected.item }}</b>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
</div>
</script>
<button type="button" class="btn btn-default" ng-click="open()">Open me!</button>
<button type="button" class="btn btn-default" ng-click="open('lg')">Large modal</button>
<button type="button" class="btn btn-default" ng-click="open('sm')">Small modal</button>
<button type="button" class="btn btn-default" ng-click="toggleAnimation()">Toggle Animation ({{ animationsEnabled }})</button>
<div ng-show="selected">Selection from a modal: {{ selected }}</div></div>
angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function ($scope, $modal, $log) {
$scope.items = ['item1', 'item2', 'item3'];
$scope.animationsEnabled = true;
$scope.open = function (size) {
var modalInstance = $modal.open({
animation: $scope.animationsEnabled,
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl',
size: size,
resolve: {
items: function () {
return $scope.items;
}
}
});
以下为JS代码:
modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem; },
最后
除了简历做到位,面试题也必不可少,整理了些题目,前面有117道汇总的面试到的题目,后面包括了HTML、CSS、JS、ES6、vue、微信小程序、项目类问题、笔试编程类题等专题。