473,386 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Angular modal dialog set inside list items

97 64KB
I'm trying to set a list of two items that open separate modal dialogs in a node.js app. I'm using Jade.

Here's the Jade:

Expand|Select|Wrap|Line Numbers
  1. button.login-button(type='button' ng-app='ng-modal') Login
  2.   ul
  3.     li(open-dialog='modal-to-open') Login
  4.       // JUST WORKING ON SIGN UP FOR NOW
  5.     li Sign Up
  6.       modal-dialog(show='dialogShown' dialog-title='My Dialog' height='100px' width='100px')
  7.         p Working
  8.     div.loginForm
  9.       form(name='loginForm' method='post' action='#' enctype='text/plain')
  10.         label(for='user') Username or Email
  11.         input(type='text' name='username' id='username' size="39" placeholder='Username or Email' required)
  12.         label(for='password') Password
  13.         input(type='password' name='password' id='password' size='39' placeholder='Password' required)
  14.  
I'm using Adam Brecht's modal dialog plugin. I have the js file and the css files attached.

I changed the declaration of the module in the js file to this:

Expand|Select|Wrap|Line Numbers
  1. app = angular.module("myApp", ["ngModal"])
This is the whole js file:

Expand|Select|Wrap|Line Numbers
  1. var app = angular.module('app', ['ngRoute']);
  2.  
  3. (function() {
  4.   var app;
  5.  
  6.  app = angular.module("myApp", ["ngModal"])
  7.  
  8.  app.provider("ngModalDefaults", function() {
  9. return {
  10.   options: {
  11.     closeButtonHtml: "<span class='ng-modal-close-x'>X</span>"
  12.   },
  13.   $get: function() {
  14.     return this.options;
  15.   },
  16.   set: function(keyOrHash, value) {
  17.     var k, v, _results;
  18.     if (typeof keyOrHash === 'object') {
  19.       _results = [];
  20.       for (k in keyOrHash) {
  21.         v = keyOrHash[k];
  22.         _results.push(this.options[k] = v);
  23.       }
  24.       return _results;
  25.     } else {
  26.       return this.options[keyOrHash] = value;
  27.     }
  28.     }
  29.   };
  30. });
  31.  
  32.    app.directive('modalDialog', [
  33. 'ngModalDefaults', '$sce', function(ngModalDefaults, $sce) {
  34.   return {
  35.     restrict: 'E',
  36.     scope: {
  37.       show: '=',
  38.       dialogTitle: '@',
  39.       onClose: '&?'
  40.     },
  41.     replace: true,
  42.     transclude: true,
  43.     link: function(scope, element, attrs) {
  44.       var setupCloseButton, setupStyle;
  45.       setupCloseButton = function() {
  46.         return scope.closeButtonHtml = $sce.trustAsHtml(ngModalDefaults.closeButtonHtml);
  47.       };
  48.       setupStyle = function() {
  49.         scope.dialogStyle = {};
  50.         if (attrs.width) {
  51.           scope.dialogStyle['width'] = attrs.width;
  52.         }
  53.         if (attrs.height) {
  54.           return scope.dialogStyle['height'] = attrs.height;
  55.         }
  56.       };
  57.       scope.hideModal = function() {
  58.         return scope.show = false;
  59.       };
  60.       scope.$watch('show', function(newVal, oldVal) {
  61.         if (newVal && !oldVal) {
  62.           document.getElementsByTagName("body")[0].style.overflow = "hidden";
  63.         } else {
  64.           document.getElementsByTagName("body")[0].style.overflow = "";
  65.         }
  66.         if ((!newVal && oldVal) && (scope.onClose != null)) {
  67.           return scope.onClose();
  68.         }
  69.       });
  70.       setupCloseButton();
  71.       return setupStyle();
  72.     },
  73.     template: "<div class='ng-modal' ng-show='show'>\n  <div class='ng-modal-overlay' ng-click='hideModal()'></div>\n  <div class='ng-modal-dialog' ng-style='dialogStyle'>\n    <span class='ng-modal-title' ng-show='dialogTitle && dialogTitle.length' ng-bind='dialogTitle'></span>\n    <div class='ng-modal-close' ng-click='hideModal()'>\n      <div ng-bind-html='closeButtonHtml'></div>\n    </div>\n    <div class='ng-modal-dialog-content' ng-transclude></div>\n  </div>\n</div>"
  74.   };
  75.  }
  76. ]);
  77.  
  78. }).call(this);
  79.  
I have the list set as a dropdown in my CSS. I wanted the form to display in a modal dialog when the link in the list is clicked, but at the moment the form displays below the dropdown box.

I have a module error in Chrome Dev Tools. I have the ng-Route module declared at the top of the ng-modal.js file. Is that not where it goes? What am I missing?
Oct 11 '15 #1

✓ answered by tdrsam

Just in case someone is looking for an answer to this question or a similar one in the future, this is what I did.

I gave up on Angular.js and went with basic, plain old jQuery to add the functionality I want.

I'm thinking of adding React.js or Vue.js in the future to run the authorization functionality etc, but haven't decided yet.

1 1931
tdrsam
97 64KB
Just in case someone is looking for an answer to this question or a similar one in the future, this is what I did.

I gave up on Angular.js and went with basic, plain old jQuery to add the functionality I want.

I'm thinking of adding React.js or Vue.js in the future to run the authorization functionality etc, but haven't decided yet.
Oct 19 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: tungchau81 | last post by:
Hi, A Modal Dialog does not allow us to highlight the text content inside <DIV> tag unless I use a <textarea> tag to display that text content. However, the situation of my software makes it...
3
by: Andrew | last post by:
I get a Null Reference Exception if I close a non-modal dialog (that is, a form opened with Show()) when a selection is made from a ComboBox. The error message refers to Unsafe Native Methods, but...
2
by: jm | last post by:
I have a parent window: <script language="javascript"> function doSearch() { result=showModalDialog("searchmni.aspx?lastname=smith"); alert(result); } </script>
3
by: Earl Teigrob | last post by:
Can a Modal Dialog Box do forms ASP.NET forms validation from within the Modal Box? I want to pop up a dialog box to the user and have it do its own post backs with validation checking and then...
2
by: Guadala Harry | last post by:
I have a frameset aspx page that enables users to upload photos. One frame/page shows a thumbnail list of prevously-uploaded images, and the other frame/page includes the controls that enable...
10
by: Guadala Harry | last post by:
I have a modal dialog that currently does all of the following except item 4. 1. lets users select a graphic from a list of thumbnails (and when selected, displays the full-size image in a...
1
by: Ganesh Ramamurthy | last post by:
Hi Experts, I am having a serious problem now. I am using IE for developing my asp.net application. My application need not run in Netscape. I have a peculiar problem. I have an aspx page from...
1
by: dan.c.roth | last post by:
oForm.Close() vs this.Close() in a modal dialog. oFrom.Close() calls Form.Dispose() but this.Close() ,say in the click event of the Form, does not. I can think of the reason for this but is...
3
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I open a window with showModalDialog. From within this modal dialog I want to redirect the dialog to another URL. I have tried all kinds of methods to redirect the page from the server and...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.