$modal
is a service that can quickly create modal windows, create partial pages, controllers, and associate them
$modal
There is only one way
open(options)
templateUrl
: The address of the modal window
template:用于显示html标签
scope
: A scope for modal content usage (in fact, $modal会创建一个当前作用域的子作用域
) defaults to$rootScope
controller
: Initializes the $scope for the $modal specified controller, which is available for $modalInstance
injection
resolve
: Defines a member and passes it to the controller specified by $modal, which is equivalent to a Reslove property of routes, and if a Objec object needs to be passed, use Angular.copy ()
backdrop
: Control background, allowable value: True (default), False (no background)," static
"-background is present, but modal window does not close when clicking outside modal window
keyboard
: When ESC is pressed, the modal dialog box is closed and the default is Ture
windowClass
: Specifies a class and is added to the modal window
The Open method returns a modal instance that has the following properties
close(result)
: Closes the modal window and passes a result
dismiss(reason)
: Undo modal method and pass a reason
result
: A contract that is passed when the modal window is closed or revoked
opened
: A contract that passes when the modal window is open and content is loaded
In addition, $modalInstance expands two methods, $close(result)
which $dismiss(reason)
are easy to close windows and do not require additional controllers
Html
1 <! DOCTYPE html> 2 Angular UI $modal using option