angularjs with angular-ui modal form










0















Hi i am beginner for angularJS and i am showing angular-ui modal form when click on button and have to add new user but i am really confusing how to handle and how to do this scenario and i tried below code but its not working can some one help me better way to do this



My requirement i want to open modal form for adding new user and when i click save button i need to add that new user in my array



main.js



 // create the module, pass in modules it depends on
var app = angular.module('myApp', ['ui.bootstrap']);
// $modal service is now available via the ui.bootstrap module we passed in to our module
app.controller('myController', ['$scope', '$uibModal', '$log',
function ($scope, $uibModal, $log)
$scope.newUser = ;
$scope.info = "";
$scope.users = [
username: "rimon", fullName: "Md. Mamunur Rashid Rimon", email: "rimonmath@gmail.com" ,
username: "shamim", fullName: "Md. Tamim Hossain", email: "shamim@gmail.com" ,
username: "tamim", fullName: "Tamim Iqbal", email: "tamim@gmail.com"
];

$scope.addUser = function ()
var modalInstance = $uibModal.open(
templateUrl: 'add_user.html',
controller: 'ModalInstanceCtrl',
);
modalInstance.result.then(function (selectedItem)
$scope.selected = selectedItem;
, function ()
$log.info('Modal dismissed at: ' + new Date());
);


$scope.saveUser = function ()
console.log("Saving...");
$scope.users.push($scope.newUser);
$scope.info = "New User Added Successfully!";
$scope.newUser = ;
;

$scope.selectUser = function (user)
$scope.clickedUser = user;
;

$scope.deleteUser = function ()
console.log($scope.users.indexOf($scope.clickedUser));
$scope.users.splice($scope.users.indexOf($scope.clickedUser), 1);
$scope.info = "User Deleted Successfully!";
;

$scope.clearInfo = function ()
$scope.info = "";
;
]);


angular.module('myApp').controller('ModalInstanceCtrl', function ($scope,$uibModalInstance)
$scope.saveUser = function ()
alert("You clicked the ok button.");
$uibModalInstance.close();
;

$scope.close = function ()
alert("You clicked the cancel button.");
$uibModalInstance.dismiss('cancel');
;
);


Form.html



<div>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">New User Registration</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Username" ng-model="newUser.username">
</div>
</div>

<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Email" ng-model="newUser.email">
</div>
</div>

<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Full Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Full Name" ng-model="newUser.fullName">
</div>
</div>

<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="saveUser();">Save</button>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="close()">Close</button>
</div>
</div>









share|improve this question
























  • Is it showing any error on the F12 DevTools?

    – Alfredo Zamudio
    Nov 15 '18 at 5:28











  • Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

    – AbhiRam
    Nov 15 '18 at 5:30











  • i am getting above error and i am not sure the way i am doing correct please suggest

    – AbhiRam
    Nov 15 '18 at 5:31











  • No one having idea about this?

    – AbhiRam
    Nov 15 '18 at 5:47











  • If it's what I'm thinking you have to register your modal controller in the app declaration. Let me formulate an answer.

    – Alfredo Zamudio
    Nov 15 '18 at 5:47















0















Hi i am beginner for angularJS and i am showing angular-ui modal form when click on button and have to add new user but i am really confusing how to handle and how to do this scenario and i tried below code but its not working can some one help me better way to do this



My requirement i want to open modal form for adding new user and when i click save button i need to add that new user in my array



main.js



 // create the module, pass in modules it depends on
var app = angular.module('myApp', ['ui.bootstrap']);
// $modal service is now available via the ui.bootstrap module we passed in to our module
app.controller('myController', ['$scope', '$uibModal', '$log',
function ($scope, $uibModal, $log)
$scope.newUser = ;
$scope.info = "";
$scope.users = [
username: "rimon", fullName: "Md. Mamunur Rashid Rimon", email: "rimonmath@gmail.com" ,
username: "shamim", fullName: "Md. Tamim Hossain", email: "shamim@gmail.com" ,
username: "tamim", fullName: "Tamim Iqbal", email: "tamim@gmail.com"
];

$scope.addUser = function ()
var modalInstance = $uibModal.open(
templateUrl: 'add_user.html',
controller: 'ModalInstanceCtrl',
);
modalInstance.result.then(function (selectedItem)
$scope.selected = selectedItem;
, function ()
$log.info('Modal dismissed at: ' + new Date());
);


$scope.saveUser = function ()
console.log("Saving...");
$scope.users.push($scope.newUser);
$scope.info = "New User Added Successfully!";
$scope.newUser = ;
;

$scope.selectUser = function (user)
$scope.clickedUser = user;
;

$scope.deleteUser = function ()
console.log($scope.users.indexOf($scope.clickedUser));
$scope.users.splice($scope.users.indexOf($scope.clickedUser), 1);
$scope.info = "User Deleted Successfully!";
;

$scope.clearInfo = function ()
$scope.info = "";
;
]);


angular.module('myApp').controller('ModalInstanceCtrl', function ($scope,$uibModalInstance)
$scope.saveUser = function ()
alert("You clicked the ok button.");
$uibModalInstance.close();
;

$scope.close = function ()
alert("You clicked the cancel button.");
$uibModalInstance.dismiss('cancel');
;
);


Form.html



<div>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">New User Registration</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Username" ng-model="newUser.username">
</div>
</div>

<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Email" ng-model="newUser.email">
</div>
</div>

<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Full Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Full Name" ng-model="newUser.fullName">
</div>
</div>

<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="saveUser();">Save</button>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="close()">Close</button>
</div>
</div>









share|improve this question
























  • Is it showing any error on the F12 DevTools?

    – Alfredo Zamudio
    Nov 15 '18 at 5:28











  • Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

    – AbhiRam
    Nov 15 '18 at 5:30











  • i am getting above error and i am not sure the way i am doing correct please suggest

    – AbhiRam
    Nov 15 '18 at 5:31











  • No one having idea about this?

    – AbhiRam
    Nov 15 '18 at 5:47











  • If it's what I'm thinking you have to register your modal controller in the app declaration. Let me formulate an answer.

    – Alfredo Zamudio
    Nov 15 '18 at 5:47













0












0








0








Hi i am beginner for angularJS and i am showing angular-ui modal form when click on button and have to add new user but i am really confusing how to handle and how to do this scenario and i tried below code but its not working can some one help me better way to do this



My requirement i want to open modal form for adding new user and when i click save button i need to add that new user in my array



main.js



 // create the module, pass in modules it depends on
var app = angular.module('myApp', ['ui.bootstrap']);
// $modal service is now available via the ui.bootstrap module we passed in to our module
app.controller('myController', ['$scope', '$uibModal', '$log',
function ($scope, $uibModal, $log)
$scope.newUser = ;
$scope.info = "";
$scope.users = [
username: "rimon", fullName: "Md. Mamunur Rashid Rimon", email: "rimonmath@gmail.com" ,
username: "shamim", fullName: "Md. Tamim Hossain", email: "shamim@gmail.com" ,
username: "tamim", fullName: "Tamim Iqbal", email: "tamim@gmail.com"
];

$scope.addUser = function ()
var modalInstance = $uibModal.open(
templateUrl: 'add_user.html',
controller: 'ModalInstanceCtrl',
);
modalInstance.result.then(function (selectedItem)
$scope.selected = selectedItem;
, function ()
$log.info('Modal dismissed at: ' + new Date());
);


$scope.saveUser = function ()
console.log("Saving...");
$scope.users.push($scope.newUser);
$scope.info = "New User Added Successfully!";
$scope.newUser = ;
;

$scope.selectUser = function (user)
$scope.clickedUser = user;
;

$scope.deleteUser = function ()
console.log($scope.users.indexOf($scope.clickedUser));
$scope.users.splice($scope.users.indexOf($scope.clickedUser), 1);
$scope.info = "User Deleted Successfully!";
;

$scope.clearInfo = function ()
$scope.info = "";
;
]);


angular.module('myApp').controller('ModalInstanceCtrl', function ($scope,$uibModalInstance)
$scope.saveUser = function ()
alert("You clicked the ok button.");
$uibModalInstance.close();
;

$scope.close = function ()
alert("You clicked the cancel button.");
$uibModalInstance.dismiss('cancel');
;
);


Form.html



<div>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">New User Registration</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Username" ng-model="newUser.username">
</div>
</div>

<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Email" ng-model="newUser.email">
</div>
</div>

<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Full Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Full Name" ng-model="newUser.fullName">
</div>
</div>

<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="saveUser();">Save</button>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="close()">Close</button>
</div>
</div>









share|improve this question
















Hi i am beginner for angularJS and i am showing angular-ui modal form when click on button and have to add new user but i am really confusing how to handle and how to do this scenario and i tried below code but its not working can some one help me better way to do this



My requirement i want to open modal form for adding new user and when i click save button i need to add that new user in my array



main.js



 // create the module, pass in modules it depends on
var app = angular.module('myApp', ['ui.bootstrap']);
// $modal service is now available via the ui.bootstrap module we passed in to our module
app.controller('myController', ['$scope', '$uibModal', '$log',
function ($scope, $uibModal, $log)
$scope.newUser = ;
$scope.info = "";
$scope.users = [
username: "rimon", fullName: "Md. Mamunur Rashid Rimon", email: "rimonmath@gmail.com" ,
username: "shamim", fullName: "Md. Tamim Hossain", email: "shamim@gmail.com" ,
username: "tamim", fullName: "Tamim Iqbal", email: "tamim@gmail.com"
];

$scope.addUser = function ()
var modalInstance = $uibModal.open(
templateUrl: 'add_user.html',
controller: 'ModalInstanceCtrl',
);
modalInstance.result.then(function (selectedItem)
$scope.selected = selectedItem;
, function ()
$log.info('Modal dismissed at: ' + new Date());
);


$scope.saveUser = function ()
console.log("Saving...");
$scope.users.push($scope.newUser);
$scope.info = "New User Added Successfully!";
$scope.newUser = ;
;

$scope.selectUser = function (user)
$scope.clickedUser = user;
;

$scope.deleteUser = function ()
console.log($scope.users.indexOf($scope.clickedUser));
$scope.users.splice($scope.users.indexOf($scope.clickedUser), 1);
$scope.info = "User Deleted Successfully!";
;

$scope.clearInfo = function ()
$scope.info = "";
;
]);


angular.module('myApp').controller('ModalInstanceCtrl', function ($scope,$uibModalInstance)
$scope.saveUser = function ()
alert("You clicked the ok button.");
$uibModalInstance.close();
;

$scope.close = function ()
alert("You clicked the cancel button.");
$uibModalInstance.dismiss('cancel');
;
);


Form.html



<div>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">New User Registration</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Username" ng-model="newUser.username">
</div>
</div>

<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Email" ng-model="newUser.email">
</div>
</div>

<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Full Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="Full Name" ng-model="newUser.fullName">
</div>
</div>

<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="saveUser();">Save</button>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="close()">Close</button>
</div>
</div>






angularjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 6:45







AbhiRam

















asked Nov 15 '18 at 5:22









AbhiRamAbhiRam

66821445




66821445












  • Is it showing any error on the F12 DevTools?

    – Alfredo Zamudio
    Nov 15 '18 at 5:28











  • Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

    – AbhiRam
    Nov 15 '18 at 5:30











  • i am getting above error and i am not sure the way i am doing correct please suggest

    – AbhiRam
    Nov 15 '18 at 5:31











  • No one having idea about this?

    – AbhiRam
    Nov 15 '18 at 5:47











  • If it's what I'm thinking you have to register your modal controller in the app declaration. Let me formulate an answer.

    – Alfredo Zamudio
    Nov 15 '18 at 5:47

















  • Is it showing any error on the F12 DevTools?

    – Alfredo Zamudio
    Nov 15 '18 at 5:28











  • Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

    – AbhiRam
    Nov 15 '18 at 5:30











  • i am getting above error and i am not sure the way i am doing correct please suggest

    – AbhiRam
    Nov 15 '18 at 5:31











  • No one having idea about this?

    – AbhiRam
    Nov 15 '18 at 5:47











  • If it's what I'm thinking you have to register your modal controller in the app declaration. Let me formulate an answer.

    – Alfredo Zamudio
    Nov 15 '18 at 5:47
















Is it showing any error on the F12 DevTools?

– Alfredo Zamudio
Nov 15 '18 at 5:28





Is it showing any error on the F12 DevTools?

– Alfredo Zamudio
Nov 15 '18 at 5:28













Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

– AbhiRam
Nov 15 '18 at 5:30





Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

– AbhiRam
Nov 15 '18 at 5:30













i am getting above error and i am not sure the way i am doing correct please suggest

– AbhiRam
Nov 15 '18 at 5:31





i am getting above error and i am not sure the way i am doing correct please suggest

– AbhiRam
Nov 15 '18 at 5:31













No one having idea about this?

– AbhiRam
Nov 15 '18 at 5:47





No one having idea about this?

– AbhiRam
Nov 15 '18 at 5:47













If it's what I'm thinking you have to register your modal controller in the app declaration. Let me formulate an answer.

– Alfredo Zamudio
Nov 15 '18 at 5:47





If it's what I'm thinking you have to register your modal controller in the app declaration. Let me formulate an answer.

– Alfredo Zamudio
Nov 15 '18 at 5:47












1 Answer
1






active

oldest

votes


















0














From what I see, your problem lies in your declaration of FormController.js please try to change this code :



app.controller('ModalInstanceCtrl', ['$scope','$modalInstance',function ($scope, $modalInstance) 
$scope.close = function ()
$modalInstance.dismiss('cancel');
;
$scope.saveUser = function()
//SUBMIT FORM HERE


]);


for this one :



angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($uibModalInstance, data) 

var pc = this;
pc.data = data;

pc.ok = function ()
//...
alert("You clicked the ok button.");
$uibModalInstance.close();
;

pc.cancel = function ()
//...
alert("You clicked the cancel button.");
$uibModalInstance.dismiss('cancel');
;
);


From your code I noticed that:



  1. Your declaration of the modal controller misses the name of the main module app which sometimes is required.


  2. you are using '$modalInstance' instead of $uibModalInstance


For further reference go here. Please try these changes and let me know if it works!






share|improve this answer























  • Hi i updated my question and i followed your code but still i getting exception when i tapped on button

    – AbhiRam
    Nov 15 '18 at 6:40











  • Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

    – AbhiRam
    Nov 15 '18 at 6:41











  • Where did i do mi stack?

    – AbhiRam
    Nov 15 '18 at 6:47











  • Which version of boostrap are you using?and if its possible let me see where you added the scripts. Something basically its wrong with the reference, bad called or bad placed.

    – Alfredo Zamudio
    Nov 15 '18 at 7:27












  • I will update please wait

    – AbhiRam
    Nov 15 '18 at 7:30











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312923%2fangularjs-with-angular-ui-modal-form%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














From what I see, your problem lies in your declaration of FormController.js please try to change this code :



app.controller('ModalInstanceCtrl', ['$scope','$modalInstance',function ($scope, $modalInstance) 
$scope.close = function ()
$modalInstance.dismiss('cancel');
;
$scope.saveUser = function()
//SUBMIT FORM HERE


]);


for this one :



angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($uibModalInstance, data) 

var pc = this;
pc.data = data;

pc.ok = function ()
//...
alert("You clicked the ok button.");
$uibModalInstance.close();
;

pc.cancel = function ()
//...
alert("You clicked the cancel button.");
$uibModalInstance.dismiss('cancel');
;
);


From your code I noticed that:



  1. Your declaration of the modal controller misses the name of the main module app which sometimes is required.


  2. you are using '$modalInstance' instead of $uibModalInstance


For further reference go here. Please try these changes and let me know if it works!






share|improve this answer























  • Hi i updated my question and i followed your code but still i getting exception when i tapped on button

    – AbhiRam
    Nov 15 '18 at 6:40











  • Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

    – AbhiRam
    Nov 15 '18 at 6:41











  • Where did i do mi stack?

    – AbhiRam
    Nov 15 '18 at 6:47











  • Which version of boostrap are you using?and if its possible let me see where you added the scripts. Something basically its wrong with the reference, bad called or bad placed.

    – Alfredo Zamudio
    Nov 15 '18 at 7:27












  • I will update please wait

    – AbhiRam
    Nov 15 '18 at 7:30















0














From what I see, your problem lies in your declaration of FormController.js please try to change this code :



app.controller('ModalInstanceCtrl', ['$scope','$modalInstance',function ($scope, $modalInstance) 
$scope.close = function ()
$modalInstance.dismiss('cancel');
;
$scope.saveUser = function()
//SUBMIT FORM HERE


]);


for this one :



angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($uibModalInstance, data) 

var pc = this;
pc.data = data;

pc.ok = function ()
//...
alert("You clicked the ok button.");
$uibModalInstance.close();
;

pc.cancel = function ()
//...
alert("You clicked the cancel button.");
$uibModalInstance.dismiss('cancel');
;
);


From your code I noticed that:



  1. Your declaration of the modal controller misses the name of the main module app which sometimes is required.


  2. you are using '$modalInstance' instead of $uibModalInstance


For further reference go here. Please try these changes and let me know if it works!






share|improve this answer























  • Hi i updated my question and i followed your code but still i getting exception when i tapped on button

    – AbhiRam
    Nov 15 '18 at 6:40











  • Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

    – AbhiRam
    Nov 15 '18 at 6:41











  • Where did i do mi stack?

    – AbhiRam
    Nov 15 '18 at 6:47











  • Which version of boostrap are you using?and if its possible let me see where you added the scripts. Something basically its wrong with the reference, bad called or bad placed.

    – Alfredo Zamudio
    Nov 15 '18 at 7:27












  • I will update please wait

    – AbhiRam
    Nov 15 '18 at 7:30













0












0








0







From what I see, your problem lies in your declaration of FormController.js please try to change this code :



app.controller('ModalInstanceCtrl', ['$scope','$modalInstance',function ($scope, $modalInstance) 
$scope.close = function ()
$modalInstance.dismiss('cancel');
;
$scope.saveUser = function()
//SUBMIT FORM HERE


]);


for this one :



angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($uibModalInstance, data) 

var pc = this;
pc.data = data;

pc.ok = function ()
//...
alert("You clicked the ok button.");
$uibModalInstance.close();
;

pc.cancel = function ()
//...
alert("You clicked the cancel button.");
$uibModalInstance.dismiss('cancel');
;
);


From your code I noticed that:



  1. Your declaration of the modal controller misses the name of the main module app which sometimes is required.


  2. you are using '$modalInstance' instead of $uibModalInstance


For further reference go here. Please try these changes and let me know if it works!






share|improve this answer













From what I see, your problem lies in your declaration of FormController.js please try to change this code :



app.controller('ModalInstanceCtrl', ['$scope','$modalInstance',function ($scope, $modalInstance) 
$scope.close = function ()
$modalInstance.dismiss('cancel');
;
$scope.saveUser = function()
//SUBMIT FORM HERE


]);


for this one :



angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($uibModalInstance, data) 

var pc = this;
pc.data = data;

pc.ok = function ()
//...
alert("You clicked the ok button.");
$uibModalInstance.close();
;

pc.cancel = function ()
//...
alert("You clicked the cancel button.");
$uibModalInstance.dismiss('cancel');
;
);


From your code I noticed that:



  1. Your declaration of the modal controller misses the name of the main module app which sometimes is required.


  2. you are using '$modalInstance' instead of $uibModalInstance


For further reference go here. Please try these changes and let me know if it works!







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 6:08









Alfredo ZamudioAlfredo Zamudio

21616




21616












  • Hi i updated my question and i followed your code but still i getting exception when i tapped on button

    – AbhiRam
    Nov 15 '18 at 6:40











  • Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

    – AbhiRam
    Nov 15 '18 at 6:41











  • Where did i do mi stack?

    – AbhiRam
    Nov 15 '18 at 6:47











  • Which version of boostrap are you using?and if its possible let me see where you added the scripts. Something basically its wrong with the reference, bad called or bad placed.

    – Alfredo Zamudio
    Nov 15 '18 at 7:27












  • I will update please wait

    – AbhiRam
    Nov 15 '18 at 7:30

















  • Hi i updated my question and i followed your code but still i getting exception when i tapped on button

    – AbhiRam
    Nov 15 '18 at 6:40











  • Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

    – AbhiRam
    Nov 15 '18 at 6:41











  • Where did i do mi stack?

    – AbhiRam
    Nov 15 '18 at 6:47











  • Which version of boostrap are you using?and if its possible let me see where you added the scripts. Something basically its wrong with the reference, bad called or bad placed.

    – Alfredo Zamudio
    Nov 15 '18 at 7:27












  • I will update please wait

    – AbhiRam
    Nov 15 '18 at 7:30
















Hi i updated my question and i followed your code but still i getting exception when i tapped on button

– AbhiRam
Nov 15 '18 at 6:40





Hi i updated my question and i followed your code but still i getting exception when i tapped on button

– AbhiRam
Nov 15 '18 at 6:40













Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

– AbhiRam
Nov 15 '18 at 6:41





Error: [$injector:unpr] errors.angularjs.org/1.7.5/$injector/…

– AbhiRam
Nov 15 '18 at 6:41













Where did i do mi stack?

– AbhiRam
Nov 15 '18 at 6:47





Where did i do mi stack?

– AbhiRam
Nov 15 '18 at 6:47













Which version of boostrap are you using?and if its possible let me see where you added the scripts. Something basically its wrong with the reference, bad called or bad placed.

– Alfredo Zamudio
Nov 15 '18 at 7:27






Which version of boostrap are you using?and if its possible let me see where you added the scripts. Something basically its wrong with the reference, bad called or bad placed.

– Alfredo Zamudio
Nov 15 '18 at 7:27














I will update please wait

– AbhiRam
Nov 15 '18 at 7:30





I will update please wait

– AbhiRam
Nov 15 '18 at 7:30



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312923%2fangularjs-with-angular-ui-modal-form%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo