1

Hi i installed the following module https://github.com/likeastore/ngDialog

it works great but i can't get how to open the dialog box from a controller, i do:

var app = angular.module('app', ['ngRoute','ngAnimate','ngSanitize','ngDialog']); app.controller('SignupController', function($rootScope,$scope) { $scope.signup = function(){ var error = false, error_list = "ERRORS"; if(!$scope.signup_username){ error = true; error_list += "\n\n Username \n " + $rootScope.errors.required_field; }if(!$scope.signup_email){ error = true; error_list += "\n\n Email \n " + $rootScope.errors.valid_email; }if(!$scope.signup_password){ error = true; error_list += "\n\n Password \n " + $rootScope.errors.required_field; } if(error){ ngDialog.open({template:error_list,plain:true}); }else{ //register } } }); 

But it doesn't works as expected, cause i get console error : ngDialog is not defined.

3
  • Why rollback my edit? I thought it was an improvement. Commented Jan 29, 2014 at 13:26
  • @Tshepang you're welcome man but it is really ok as it is :) Commented Jan 29, 2014 at 14:12
  • Not really. It has a tag in the title; not acceptable around here. Commented Jan 29, 2014 at 14:19

1 Answer 1

8

Your controller is not taking a dependency on ngDialog so it is an unknown variable at runtime.

app.controller('SignupController', function($rootScope, $scope, ngDialog) { $scope.signup = function(){ var error = false, error_list = "ERRORS"; if(!$scope.signup_username){ error = true; error_list += "\n\n Username \n " + $rootScope.errors.required_field; }if(!$scope.signup_email){ error = true; error_list += "\n\n Email \n " + $rootScope.errors.valid_email; }if(!$scope.signup_password){ error = true; error_list += "\n\n Password \n " + $rootScope.errors.required_field; } if(error){ ngDialog.open({template:error_list,plain:true}); }else{ //register } } }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.