AngularStrap -- Modal

2 篇文章 0 订阅
1 篇文章 0 订阅

AngularStrap – Bootstrap wrapper for AngularJS

  • About the AngularStrap project
    AngularStrap is a set of native directives that enables seamless integration of Bootstrap#^3.0 into your AngularJS#^1.2 application.

With no external dependency except the Bootstrap CSS styles, AngularStrap is light and fast. It has been built from the ground up to leverage ngAnimate!

AngularStrap is tested against the latest patch release of the 1.2, 1.3 and 1.4 branches.

  • AngularStrap Modal
    这里简单介绍在AngularJS使用Bootstrap UI中Modal对话框。
<!-- Button to trigger a default modal with a scope as an object {title:'', content:'', etc.} -->
<button type="button" class="btn btn-lg btn-primary" data-animation="am-fade-and-scale" data-placement="center" bs-modal="modal">Click to toggle modal
  <br>
  <small>(using an object)</small>
</button>

<!-- You can use a custom html template with the `data-template` attr -->
<button type="button" class="btn btn-lg btn-danger" data-animation="am-fade-and-slide-top" data-template-url="modal/docs/modal.demo.tpl.html" bs-modal="modal">Custom Modal
  <br>
  <small>(using data-template)</small>
</button>

<!-- You can use a custom html template with the `data-template` attr -->
<button type="button" class="btn btn-lg btn-danger" ng-click="showModal()">Modal
  <br>
  <small>(using service)</small>
</button>

这里定义了3个按钮,分别弹出一个modal对话框。效果如下。

这里写图片描述
这个modal dialog显示在屏幕中心。modal 使用了一个简单地对象:

{
  "title": "Title",
  "content": "Hello Modal<br />This is a multiline message!"
};

第二个modal使用了一个html的模板,内容由模板来确定。
这里写图片描述

第三个modal使用自定义的js函数处理显示。
这里写图片描述

  • 如何使用Usage
    Append a bs-modal attribute to any element to activate the directive. 推荐使用html5的attruibute – data-bs-modal。

*The module also exposes a $modal service
Available for programmatic use (inside a directive/controller).*

angular.module('myApp')
.controller('DemoCtrl', function($scope, $modal) {
  // Show a basic modal from a controller
  var myModal = $modal({title: 'My Title', content: 'My Content', show: true});

  // Pre-fetch an external template populated with a custom scope
  var myOtherModal = $modal({scope: $scope, template: 'modal/docs/modal.demo.tpl.html', show: false});
  // Show when some event occurs (use $promise property to ensure the template has been loaded)
  $scope.showModal = function() {
    myOtherModal.$promise.then(myOtherModal.show);
  };
})
  • 选项 Options
    Options can be passed via data-attributes on the directive or as an object hash to configure the service. For data attributes, append the option name to data-, as in data-animation=**.

For directives, you can naturally inherit the contextual $scope or leverage a custom one with an AngularJS expression to evaluate as an object directly on the bs-modal attribute


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值