Bindings are undefined when trying to open uib modal Instance
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
We are using angular version 1.5.10 and ui-router version 0.3.1. We are componentify our controller and services.
When we are trying to open modal pop up using $uibModal.open method. It is opening the template of the component in the modal pop up. But it is not showing any of the data passed to the controller opened in the modal, using resolve
project Component from where we have to call is as follows -
import * as angular from 'angular';
export let ProjectComponent = {
selector: 'ProjectDetails',
templateUrl: 'app/entities/project-details/project-details.html',
bindings: {},
controller: ProjectController,
controllerAs: 'vm'
};
ProjectController.$inject = ['project', '$http', '$scope', '$filter', '$uibModal', 'Record'];
function ProjectController(project, $http, $scope, $filter, $uibModal, Record) {
var vm = this;
var modalInstance = $uibModal.open({
template: '<project-task-details $resolve="$resolve" ></project-task-details>',
backdrop: 'static',
windowClass: 'viewerModal style-1',
size: 'lg',
resolve: {
data: function() {
return project.getTaskDetails({
projectId: projectId
});
}
}
});
}
angular
.module('projectApp')
.component(ProjectComponent.selector, ProjectComponent);
Project Service which is using from this Project component -
import * as angular from 'angular';
class project {
constructor($http) {
this.$http = $http;
}
getTaskDetails(params) {
return this.$http.get('api/project' + '/' + params.projectId).success((response) => response.data);
}
}
angular
.module('projectApp')
.service('project', project);
project.$inject = ['$http'];
export default project;
Now the page content which we are trying to load i.e. ProjectTaskDetailComponent:-
import angular from 'angular';
export let ProjectTaskDetailComponent = {
selector: "projectTaskDetails",
templateUrl: 'app/entities/project-details/project-task-details.html',
bindings: {
// modalInstance: '<',
data: '<'
},
controller: ProjectTaskDetailController,
controllerAs: 'vm'
};
ProjectTaskDetailController.$inject = ;
function ProjectTaskDetailController() {
var vm = this;
vm.$onInit = function() {
vm.projectDetail = this.data;
}
// vm.projectDetail = data;
vm.clear = clear;
setTimeout(function() {
$('#loadingImg').css('display', 'none');
}, 1000);
function clear() {
// $uibModalInstance.dismiss('cancel');
}
}
angular
.module('projectApp')
.component(ProjectTaskDetailComponent.selector, ProjectTaskDetailComponent);
I tried to open modal pop up which is opened without data. When we debug the code, the data in bindings is undefined in ProjectTaskdetailComponent when in template we pass as data = "$resolve.data". If we use $resolve = "$resolve" in template, still data is undefined while we check in ProjectTaskdetailComponent.
Also tried all bindings like data: "<", data: "=", data: "@", but the same issue persists i.e. data is undefined.
Also tried to update the angular-ui-router to 0.4.2 version but it still didn't work.
angularjs angular-ui-router angular-ui-bootstrap
add a comment |
We are using angular version 1.5.10 and ui-router version 0.3.1. We are componentify our controller and services.
When we are trying to open modal pop up using $uibModal.open method. It is opening the template of the component in the modal pop up. But it is not showing any of the data passed to the controller opened in the modal, using resolve
project Component from where we have to call is as follows -
import * as angular from 'angular';
export let ProjectComponent = {
selector: 'ProjectDetails',
templateUrl: 'app/entities/project-details/project-details.html',
bindings: {},
controller: ProjectController,
controllerAs: 'vm'
};
ProjectController.$inject = ['project', '$http', '$scope', '$filter', '$uibModal', 'Record'];
function ProjectController(project, $http, $scope, $filter, $uibModal, Record) {
var vm = this;
var modalInstance = $uibModal.open({
template: '<project-task-details $resolve="$resolve" ></project-task-details>',
backdrop: 'static',
windowClass: 'viewerModal style-1',
size: 'lg',
resolve: {
data: function() {
return project.getTaskDetails({
projectId: projectId
});
}
}
});
}
angular
.module('projectApp')
.component(ProjectComponent.selector, ProjectComponent);
Project Service which is using from this Project component -
import * as angular from 'angular';
class project {
constructor($http) {
this.$http = $http;
}
getTaskDetails(params) {
return this.$http.get('api/project' + '/' + params.projectId).success((response) => response.data);
}
}
angular
.module('projectApp')
.service('project', project);
project.$inject = ['$http'];
export default project;
Now the page content which we are trying to load i.e. ProjectTaskDetailComponent:-
import angular from 'angular';
export let ProjectTaskDetailComponent = {
selector: "projectTaskDetails",
templateUrl: 'app/entities/project-details/project-task-details.html',
bindings: {
// modalInstance: '<',
data: '<'
},
controller: ProjectTaskDetailController,
controllerAs: 'vm'
};
ProjectTaskDetailController.$inject = ;
function ProjectTaskDetailController() {
var vm = this;
vm.$onInit = function() {
vm.projectDetail = this.data;
}
// vm.projectDetail = data;
vm.clear = clear;
setTimeout(function() {
$('#loadingImg').css('display', 'none');
}, 1000);
function clear() {
// $uibModalInstance.dismiss('cancel');
}
}
angular
.module('projectApp')
.component(ProjectTaskDetailComponent.selector, ProjectTaskDetailComponent);
I tried to open modal pop up which is opened without data. When we debug the code, the data in bindings is undefined in ProjectTaskdetailComponent when in template we pass as data = "$resolve.data". If we use $resolve = "$resolve" in template, still data is undefined while we check in ProjectTaskdetailComponent.
Also tried all bindings like data: "<", data: "=", data: "@", but the same issue persists i.e. data is undefined.
Also tried to update the angular-ui-router to 0.4.2 version but it still didn't work.
angularjs angular-ui-router angular-ui-bootstrap
add a comment |
We are using angular version 1.5.10 and ui-router version 0.3.1. We are componentify our controller and services.
When we are trying to open modal pop up using $uibModal.open method. It is opening the template of the component in the modal pop up. But it is not showing any of the data passed to the controller opened in the modal, using resolve
project Component from where we have to call is as follows -
import * as angular from 'angular';
export let ProjectComponent = {
selector: 'ProjectDetails',
templateUrl: 'app/entities/project-details/project-details.html',
bindings: {},
controller: ProjectController,
controllerAs: 'vm'
};
ProjectController.$inject = ['project', '$http', '$scope', '$filter', '$uibModal', 'Record'];
function ProjectController(project, $http, $scope, $filter, $uibModal, Record) {
var vm = this;
var modalInstance = $uibModal.open({
template: '<project-task-details $resolve="$resolve" ></project-task-details>',
backdrop: 'static',
windowClass: 'viewerModal style-1',
size: 'lg',
resolve: {
data: function() {
return project.getTaskDetails({
projectId: projectId
});
}
}
});
}
angular
.module('projectApp')
.component(ProjectComponent.selector, ProjectComponent);
Project Service which is using from this Project component -
import * as angular from 'angular';
class project {
constructor($http) {
this.$http = $http;
}
getTaskDetails(params) {
return this.$http.get('api/project' + '/' + params.projectId).success((response) => response.data);
}
}
angular
.module('projectApp')
.service('project', project);
project.$inject = ['$http'];
export default project;
Now the page content which we are trying to load i.e. ProjectTaskDetailComponent:-
import angular from 'angular';
export let ProjectTaskDetailComponent = {
selector: "projectTaskDetails",
templateUrl: 'app/entities/project-details/project-task-details.html',
bindings: {
// modalInstance: '<',
data: '<'
},
controller: ProjectTaskDetailController,
controllerAs: 'vm'
};
ProjectTaskDetailController.$inject = ;
function ProjectTaskDetailController() {
var vm = this;
vm.$onInit = function() {
vm.projectDetail = this.data;
}
// vm.projectDetail = data;
vm.clear = clear;
setTimeout(function() {
$('#loadingImg').css('display', 'none');
}, 1000);
function clear() {
// $uibModalInstance.dismiss('cancel');
}
}
angular
.module('projectApp')
.component(ProjectTaskDetailComponent.selector, ProjectTaskDetailComponent);
I tried to open modal pop up which is opened without data. When we debug the code, the data in bindings is undefined in ProjectTaskdetailComponent when in template we pass as data = "$resolve.data". If we use $resolve = "$resolve" in template, still data is undefined while we check in ProjectTaskdetailComponent.
Also tried all bindings like data: "<", data: "=", data: "@", but the same issue persists i.e. data is undefined.
Also tried to update the angular-ui-router to 0.4.2 version but it still didn't work.
angularjs angular-ui-router angular-ui-bootstrap
We are using angular version 1.5.10 and ui-router version 0.3.1. We are componentify our controller and services.
When we are trying to open modal pop up using $uibModal.open method. It is opening the template of the component in the modal pop up. But it is not showing any of the data passed to the controller opened in the modal, using resolve
project Component from where we have to call is as follows -
import * as angular from 'angular';
export let ProjectComponent = {
selector: 'ProjectDetails',
templateUrl: 'app/entities/project-details/project-details.html',
bindings: {},
controller: ProjectController,
controllerAs: 'vm'
};
ProjectController.$inject = ['project', '$http', '$scope', '$filter', '$uibModal', 'Record'];
function ProjectController(project, $http, $scope, $filter, $uibModal, Record) {
var vm = this;
var modalInstance = $uibModal.open({
template: '<project-task-details $resolve="$resolve" ></project-task-details>',
backdrop: 'static',
windowClass: 'viewerModal style-1',
size: 'lg',
resolve: {
data: function() {
return project.getTaskDetails({
projectId: projectId
});
}
}
});
}
angular
.module('projectApp')
.component(ProjectComponent.selector, ProjectComponent);
Project Service which is using from this Project component -
import * as angular from 'angular';
class project {
constructor($http) {
this.$http = $http;
}
getTaskDetails(params) {
return this.$http.get('api/project' + '/' + params.projectId).success((response) => response.data);
}
}
angular
.module('projectApp')
.service('project', project);
project.$inject = ['$http'];
export default project;
Now the page content which we are trying to load i.e. ProjectTaskDetailComponent:-
import angular from 'angular';
export let ProjectTaskDetailComponent = {
selector: "projectTaskDetails",
templateUrl: 'app/entities/project-details/project-task-details.html',
bindings: {
// modalInstance: '<',
data: '<'
},
controller: ProjectTaskDetailController,
controllerAs: 'vm'
};
ProjectTaskDetailController.$inject = ;
function ProjectTaskDetailController() {
var vm = this;
vm.$onInit = function() {
vm.projectDetail = this.data;
}
// vm.projectDetail = data;
vm.clear = clear;
setTimeout(function() {
$('#loadingImg').css('display', 'none');
}, 1000);
function clear() {
// $uibModalInstance.dismiss('cancel');
}
}
angular
.module('projectApp')
.component(ProjectTaskDetailComponent.selector, ProjectTaskDetailComponent);
I tried to open modal pop up which is opened without data. When we debug the code, the data in bindings is undefined in ProjectTaskdetailComponent when in template we pass as data = "$resolve.data". If we use $resolve = "$resolve" in template, still data is undefined while we check in ProjectTaskdetailComponent.
Also tried all bindings like data: "<", data: "=", data: "@", but the same issue persists i.e. data is undefined.
Also tried to update the angular-ui-router to 0.4.2 version but it still didn't work.
angularjs angular-ui-router angular-ui-bootstrap
angularjs angular-ui-router angular-ui-bootstrap
edited Jan 4 at 6:25
ajain
261115
261115
asked Jan 3 at 13:46
Geetanjali JainGeetanjali Jain
170115
170115
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Try using component instead of template in your uibModal.open.
From the docs:
component (Type: string, Example: myComponent) - A string reference to the component to be rendered that is registered with Angular's compiler. If using a directive, the directive must have restrict: 'E' and a template or templateUrl set.
It supports these bindings:
close - A method that can be used to close a modal, passing a result. The result must be passed in this format: {$value: myResult}
dismiss - A method that can be used to dismiss a modal, passing a result. The result must be passed in this format: {$value: myRejectedResult}
modalInstance - The modal instance. This is the same $uibModalInstance injectable found when using controller.
resolve - An object of the modal resolve values. See UI Router resolves for details.
So in your case, it might look something like:
var modalInstance = $uibModal.open({
component: 'projectTaskDetails',
backdrop: 'static',
windowClass: 'viewerModal style-1',
size: 'lg',
resolve: {
data: function() {
return project.getTaskDetails({
projectId: projectId
});
}
}
});
}
Edit: Your component bindings will need to conform to their api, so it should look like:
export let ProjectTaskDetailComponent = {
selector: "projectTaskDetails",
templateUrl: 'app/entities/project-details/project-task-details.html',
bindings: {
modalInstance: '<',
resolve: '<'
},
controller: ProjectTaskDetailController,
controllerAs: 'vm'
};
add a comment |
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
});
}
});
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%2f54023541%2fbindings-are-undefined-when-trying-to-open-uib-modal-instance%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
Try using component instead of template in your uibModal.open.
From the docs:
component (Type: string, Example: myComponent) - A string reference to the component to be rendered that is registered with Angular's compiler. If using a directive, the directive must have restrict: 'E' and a template or templateUrl set.
It supports these bindings:
close - A method that can be used to close a modal, passing a result. The result must be passed in this format: {$value: myResult}
dismiss - A method that can be used to dismiss a modal, passing a result. The result must be passed in this format: {$value: myRejectedResult}
modalInstance - The modal instance. This is the same $uibModalInstance injectable found when using controller.
resolve - An object of the modal resolve values. See UI Router resolves for details.
So in your case, it might look something like:
var modalInstance = $uibModal.open({
component: 'projectTaskDetails',
backdrop: 'static',
windowClass: 'viewerModal style-1',
size: 'lg',
resolve: {
data: function() {
return project.getTaskDetails({
projectId: projectId
});
}
}
});
}
Edit: Your component bindings will need to conform to their api, so it should look like:
export let ProjectTaskDetailComponent = {
selector: "projectTaskDetails",
templateUrl: 'app/entities/project-details/project-task-details.html',
bindings: {
modalInstance: '<',
resolve: '<'
},
controller: ProjectTaskDetailController,
controllerAs: 'vm'
};
add a comment |
Try using component instead of template in your uibModal.open.
From the docs:
component (Type: string, Example: myComponent) - A string reference to the component to be rendered that is registered with Angular's compiler. If using a directive, the directive must have restrict: 'E' and a template or templateUrl set.
It supports these bindings:
close - A method that can be used to close a modal, passing a result. The result must be passed in this format: {$value: myResult}
dismiss - A method that can be used to dismiss a modal, passing a result. The result must be passed in this format: {$value: myRejectedResult}
modalInstance - The modal instance. This is the same $uibModalInstance injectable found when using controller.
resolve - An object of the modal resolve values. See UI Router resolves for details.
So in your case, it might look something like:
var modalInstance = $uibModal.open({
component: 'projectTaskDetails',
backdrop: 'static',
windowClass: 'viewerModal style-1',
size: 'lg',
resolve: {
data: function() {
return project.getTaskDetails({
projectId: projectId
});
}
}
});
}
Edit: Your component bindings will need to conform to their api, so it should look like:
export let ProjectTaskDetailComponent = {
selector: "projectTaskDetails",
templateUrl: 'app/entities/project-details/project-task-details.html',
bindings: {
modalInstance: '<',
resolve: '<'
},
controller: ProjectTaskDetailController,
controllerAs: 'vm'
};
add a comment |
Try using component instead of template in your uibModal.open.
From the docs:
component (Type: string, Example: myComponent) - A string reference to the component to be rendered that is registered with Angular's compiler. If using a directive, the directive must have restrict: 'E' and a template or templateUrl set.
It supports these bindings:
close - A method that can be used to close a modal, passing a result. The result must be passed in this format: {$value: myResult}
dismiss - A method that can be used to dismiss a modal, passing a result. The result must be passed in this format: {$value: myRejectedResult}
modalInstance - The modal instance. This is the same $uibModalInstance injectable found when using controller.
resolve - An object of the modal resolve values. See UI Router resolves for details.
So in your case, it might look something like:
var modalInstance = $uibModal.open({
component: 'projectTaskDetails',
backdrop: 'static',
windowClass: 'viewerModal style-1',
size: 'lg',
resolve: {
data: function() {
return project.getTaskDetails({
projectId: projectId
});
}
}
});
}
Edit: Your component bindings will need to conform to their api, so it should look like:
export let ProjectTaskDetailComponent = {
selector: "projectTaskDetails",
templateUrl: 'app/entities/project-details/project-task-details.html',
bindings: {
modalInstance: '<',
resolve: '<'
},
controller: ProjectTaskDetailController,
controllerAs: 'vm'
};
Try using component instead of template in your uibModal.open.
From the docs:
component (Type: string, Example: myComponent) - A string reference to the component to be rendered that is registered with Angular's compiler. If using a directive, the directive must have restrict: 'E' and a template or templateUrl set.
It supports these bindings:
close - A method that can be used to close a modal, passing a result. The result must be passed in this format: {$value: myResult}
dismiss - A method that can be used to dismiss a modal, passing a result. The result must be passed in this format: {$value: myRejectedResult}
modalInstance - The modal instance. This is the same $uibModalInstance injectable found when using controller.
resolve - An object of the modal resolve values. See UI Router resolves for details.
So in your case, it might look something like:
var modalInstance = $uibModal.open({
component: 'projectTaskDetails',
backdrop: 'static',
windowClass: 'viewerModal style-1',
size: 'lg',
resolve: {
data: function() {
return project.getTaskDetails({
projectId: projectId
});
}
}
});
}
Edit: Your component bindings will need to conform to their api, so it should look like:
export let ProjectTaskDetailComponent = {
selector: "projectTaskDetails",
templateUrl: 'app/entities/project-details/project-task-details.html',
bindings: {
modalInstance: '<',
resolve: '<'
},
controller: ProjectTaskDetailController,
controllerAs: 'vm'
};
edited Jan 7 at 2:13
answered Jan 7 at 2:08
Andrew LahikainenAndrew Lahikainen
31019
31019
add a comment |
add a comment |
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%2f54023541%2fbindings-are-undefined-when-trying-to-open-uib-modal-instance%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