Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
angular2-bootstrap-confirm
Advanced tools
http://mattlewis92.github.io/angular2-bootstrap-confirm/
A simple angular2 directive to display a bootstrap styled confirmation popover when an element is clicked.
Pull requests are welcome.
Install through npm:
npm install --save @angular/core@2.0.0-rc.1 angular2-bootstrap-confirm
Then use it in your app on a component:
import {Component, provide} from '@angular/core';
import {Confirm, ConfirmOptions, Position} from 'angular2-bootstrap-confirm';
import {PositionService} from 'ng2-bootstrap/components/position';
// Or if you don't want to depend on the ng2-bootstrap module, use the bundled position service:
// import {PositionService} from 'angular2-bootstrap-confirm/position/position';
@Component({
selector: 'my-component',
providers: [ // you can pass both of these when bootstrapping the app to configure globally throughout your app
ConfirmOptions,
provide(Position, {useClass: PositionService}) // this is required so you can use the bundled position service rather than rely on the `ng2-bootstrap` module
],
directives: [
Confirm
],
template: `
<button
class="btn btn-default"
mwl-confirm
[title]="title"
[message]="message"
placement="left"
(confirm)="confirmClicked = true"
(cancel)="cancelClicked = true"
[(isOpen)]="isOpen">
Click me!
</button>
`
})
class MyComponent {
public title: string = 'Popover title';
public message: string = 'Popover description';
public confirmClicked: boolean = false;
public cancelClicked: boolean = false;
public isOpen: boolean = false;
}
You may also find it useful to view the demo source.
<script src="node_modules/angular2-bootstrap-confirm/position/position.js"></script>
<script src="node_modules/angular2-bootstrap-confirm/angular2-bootstrap-confirm.js"></script>
<script>
// position service available as ng2BootstrapPosition.PositionService
// confirm options, directive and position token available as ng2BootstrapConfirm.ConfirmOptions, ng2BootstrapConfirm.Confirm, ng2BootstrapConfirm.Position
</script>
All options can be configured either on a per directive instance (see previous example of how to) or globally via a the ConfirmOptions
provider
To configure globally you need to configure the provider in your app or directive like so:
providers: [
provide(ConfirmOptions, {
useFactory: (): ConfirmOptions => {
return new ConfirmOptions({
focusButton: 'confirm' // focus the confirm button by default. See below for an explanation of all options.
});
}
})
]
An explanation of each option available is as follows:
The title of the popover. Note, if you use an expression, you may want to consider using "data-title" instead of "title" so that the browser doesn't show native tooltips with the angular expression listed.
The body text of the popover.
The text of the confirm button. Default Confirm
The text of the cancel button. Default Cancel
The placement of the popover. It can be either top
, right
, bottom
or left
. Default top
An expression that is called when the confirm button is clicked.
An expression that is called when the cancel button is clicked.
The bootstrap button type of the confirm button. It can be any supported bootstrap color type e.g. default
, warning
, danger
etc. Default success
The bootstrap button type of the cancel button. It can be any supported bootstrap color type e.g. default
, warning
, danger
etc. Default default
A 2-way bound variable to control if the popover is currently open or not.
Set to either confirm
or cancel
to focus the confirm or cancel button. If omitted, by default it will not focus either button.
Whether to disable showing the popover. Default false
.
Whether to hide the confirm button. Default false
.
Whether to hide the cancel button. Default false
.
npm install
while current directory is this repoRun npm start
to start a development server on port 8000 with auto reload + tests.
Run npm test
to run tests once or npm run test:watch
to continually run tests.
MIT
FAQs
An angular2 bootstrap confirmation popover
We found that angular2-bootstrap-confirm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.