angularjs with angular-ui modal form
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">×</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
|
show 1 more comment
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">×</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
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
|
show 1 more comment
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">×</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
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">×</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
angularjs
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
|
show 1 more comment
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
|
show 1 more comment
1 Answer
1
active
oldest
votes
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:
Your declaration of the modal controller misses the name of the main module app which sometimes is required.
you are using '$modalInstance' instead of $uibModalInstance
For further reference go here. Please try these changes and let me know if it works!
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
|
show 5 more comments
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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:
Your declaration of the modal controller misses the name of the main module app which sometimes is required.
you are using '$modalInstance' instead of $uibModalInstance
For further reference go here. Please try these changes and let me know if it works!
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
|
show 5 more comments
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:
Your declaration of the modal controller misses the name of the main module app which sometimes is required.
you are using '$modalInstance' instead of $uibModalInstance
For further reference go here. Please try these changes and let me know if it works!
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
|
show 5 more comments
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:
Your declaration of the modal controller misses the name of the main module app which sometimes is required.
you are using '$modalInstance' instead of $uibModalInstance
For further reference go here. Please try these changes and let me know if it works!
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:
Your declaration of the modal controller misses the name of the main module app which sometimes is required.
you are using '$modalInstance' instead of $uibModalInstance
For further reference go here. Please try these changes and let me know if it works!
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
|
show 5 more comments
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
|
show 5 more comments
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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