Detailed example of how to use ngModal modal box in AngularJS
This article mainly introduces the example of using ngModal modal box in AngularJS. The editor thinks it is quite good. Now I will share it with you and give it as a reference. Let’s follow the editor and take a look.
Using modal boxes in AngularJS requires referencing files:
angular.js 1.5.5
ui.bootstrap-tpls.js 0.11.2
bootstrap.css 3.3.7
It should be noted that the versions must be consistent. Higher versions do not support this method and an error will occur.
Write the content of the modal box that needs to pop up in the script tag and indicate Attribute, put it in the page
<script type="text/ng-template" id="modal.html"> <p> <p class="modal-header"> <h3 class="modal-title" align="center"> 标题信息 </h3> </p> <p class="modal-body"> <p align="center"> 模态框内容 </p> </p> <p class="modal-footer"> <button class="btn btn-primary" ng-click="ok()"> 确认 </button> <button class="btn btn-warning" ng-click="cancel()"> 退出 </button> </p> </p> </script>
Inject modal box in App and Controller
var app = angular.module('app', ['ui.bootstrap']); app.controller('modalController', function($scope, $rootScope,$modal) { $scope.openModel = function() { var modalInstance = $modal.open({ templateUrl : 'modal.html',//script标签中定义的id controller : 'modalCtrl',//modal对应的Controller resolve : { data : function() {//data作为modal的controller传入的参数 return data;//用于传递数据 } } }) } } //模态框对应的Controller app.controller('modalCtrl', function($scope, $modalInstance, data) { $scope.data= data; //在这里处理要进行的操作 $scope.ok = function() { $modalInstance.close(); }; $scope.cancel = function() { $modalInstance.dismiss('cancel'); } });
AddEventTrigger display of modal box
<button ng-click="openModal()">打开模态框</button>
html
ng-model模态框 <button ng-click="openModal()">打开模态框</button>
The above is the detailed content of Detailed example of how to use ngModal modal box in AngularJS. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Javascript is a very unique language. It is unique in terms of the organization of the code, the programming paradigm of the code, and the object-oriented theory. The issue of whether Javascript is an object-oriented language that has been debated for a long time has obviously been There is an answer. However, even though Javascript has been dominant for twenty years, if you want to understand popular frameworks such as jQuery, Angularjs, and even React, just watch the "Black Horse Cloud Classroom JavaScript Advanced Framework Design Video Tutorial".

In today's information age, websites have become an important tool for people to obtain information and communicate. A responsive website can adapt to various devices and provide users with a high-quality experience, which has become a hot spot in modern website development. This article will introduce how to use PHP and AngularJS to build a responsive website to provide a high-quality user experience. Introduction to PHP PHP is an open source server-side programming language ideal for web development. PHP has many advantages, such as easy to learn, cross-platform, rich tool library, development efficiency

With the continuous development of the Internet, Web applications have become an important part of enterprise information construction and a necessary means of modernization work. In order to make web applications easy to develop, maintain and expand, developers need to choose a technical framework and programming language that suits their development needs. PHP and AngularJS are two very popular web development technologies. They are server-side and client-side solutions respectively. Their combined use can greatly improve the development efficiency and user experience of web applications. Advantages of PHPPHP

HTML, CSS and jQuery: Build a beautiful modal box Introduction: Pop-up windows or modal boxes are often used in web pages to display information and achieve interactive effects. This article will introduce how to use HTML, CSS and jQuery to build a beautiful modal box, with specific code examples. 1. HTML structure: First, we need to create an HTML structure to accommodate the modal box. The code looks like this: <!DOCTYPEhtml><html>

How to use Vue to implement modal box special effects With the development of Internet technology, modal boxes (Modal) are widely used in web design as a common interaction method. Modal boxes can be used to display pop-up windows, warnings, confirmations and other information to give users a better interactive experience. This article will introduce how to use the Vue framework to implement a simple modal box effect and provide specific code examples. The following are the steps to implement modal box effects: Create a Vue instance. First, we need to introduce the Vue CDN link in the HTML file and add it in Ja

How to implement dialog boxes and modal boxes in Vue? With the continuous development and updating of front-end technology, the development of front-end pages has become more and more complex and diverse. Dialog boxes and modal boxes are elements that often appear in front-end pages and can help us achieve more flexible and diverse interactive effects. In Vue, there are many ways to implement dialog boxes and modal boxes. This article will introduce you to several common implementation methods. 1. Use Vue’s own components. Vue.js provides some built-in components, such as transition and tra.

With the popularity of the Internet, more and more people are using the network to transfer and share files. However, due to various reasons, using traditional methods such as FTP for file management cannot meet the needs of modern users. Therefore, establishing an easy-to-use, efficient, and secure online file management platform has become a trend. The online file management platform introduced in this article is based on PHP and AngularJS. It can easily perform file upload, download, edit, delete and other operations, and provides a series of powerful functions, such as file sharing, search,

With the rapid development of Web technology, Single Page Web Application (SinglePage Application, SPA) has become an increasingly popular Web application model. Compared with traditional multi-page web applications, the biggest advantage of SPA is that the user experience is smoother, and the computing pressure on the server is also greatly reduced. In this article, we will introduce how to build a simple SPA using Flask and AngularJS. Flask is a lightweight Py
