Coder Social home page Coder Social logo

angular-ask's Introduction

angular-ask

DEMO:

http://cheiron1990.github.io/angular-ask/demo.html

使用说明

1 HTML和CSS:

<!-- Material Design 主题 -->
<head>
    <link rel="stylesheet" href="styles/css/angular-ask-material.min.css" id="notifyTheme">
<head>
<body>
    <!-- 你的内容 -->
    <div ngask id="ngask"></div>  <!-- 容器标签 -->
    <!-- 引入jQuery文件 -->
    <!-- 引入Angular文件 -->
    <script src="scripts/dist/angular-ask.min.js"></script>
</body>
<!-- Fullscreen Design 主题 -->
<!-- 强烈建议整个页面都是深色调时再用,不然容易看不清,详见DEMO -->
<head>
    <link rel="stylesheet" href="styles/css/angular-ask-fullscreen.min.css" id="notifyTheme">
<head>
<body>
    <div class="ngask-blur">  <!-- 用这个标签包裹内容,用于背景模糊效果 -->
        <!-- 你的全部内容 -->
    </div>
    <div ngask id="ngask"></div>  <!-- 容器标签 -->
    <!-- 引入jQuery文件 -->
    <!-- 引入Angular文件 -->
    <script src="scripts/dist/angular-ask.min.js"></script>
</body>

2 Javascript:

angular.module('yourApp', ['angularAsk']);

3 需要显示通知时触发事件 ngAskConfirm 或者 ngAskPrompt,传入三个参数,依次是title, content或用于prompt输入框的placeholder文本,回调函数。回调函数自带参数btnClicked, 当用户点击OK时,为true,点击Cancel时,为false. 如果是ngAskPrompt, 回调还有第二个参数userInput, 值是用户的输入,如果用户点击cancel,值为undefined:

// Confirm
var confirmCallback = function(btnClicked){};
$scope.$emit('ngAskConfirm', 'title', 'content', confirmCallback);

// Prompt
var promptCallback = function(btnClicked, userInput){};
$scope.$emit('ngAskPrompt', 'title', 'placeholder', promptCallback);

Guide

1 HTML and CSS:

<!-- Material Design Theme -->
<head>
    <link rel="stylesheet" href="styles/css/angular-ask-material.min.css" id="notifyTheme">
<head>
<body>
    <!-- Your Content -->
    <div ngask id="ngask"></div>  <!-- Container Tag -->
    <!-- import jQuery file -->
    <!-- import Angular file -->
    <script src="scripts/dist/angular-ask.min.js"></script>
</body>
<!-- Fullscreen Design Theme -->
<!-- _Attention!_ Use this theme only when your page with deep tones, or users may not see content clearly. See the demo page to feel this sentence.-->
<head>
    <link rel="stylesheet" href="styles/css/angular-ask-fullscreen.min.css" id="notifyTheme">
<head>
<body>
    <div class="ngask-blur">  <!-- For the background blur effect, Use this tag to wrap all your content. -->
        <!-- All your content -->
    </div>
    <div ngask id="ngask"></div>  <!-- Container Tag -->
    <!-- import jQuery file -->
    <!-- import Angular file -->
    <script src="scripts/dist/angular-ask.min.js"></script>
</body>

2 Javascript:

angular.module('yourApp', ['angularAsk']);

3 When you want to ask something, trigger a ngAskConfirm or ngAskPrompt event, and pass 3 arguments: title, content or placeholder used in prompt input, callback function. The callback function has an argument btnClicked, when users click OK button, it will be true, while users click cancel button, it will be false. When you use ngAskPrompt, the callback function has another argument userInput, when users click OK button, it will be users' input, while users click cancel button, it will be undefined.

// Confirm
var confirmCallback = function(btnClicked){};
$scope.$emit('ngAskConfirm', 'title', 'content', confirmCallback);

// Prompt
var promptCallback = function(btnClicked, userInput){};
$scope.$emit('ngAskPrompt', 'title', 'placeholder', promptCallback);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.