Answer the question
In order to leave comments, you need to log in
Angularjs, How to pass data to bootstrap modal?
I'm dabbling in Angularjs and having a problem passing data to a modal window.
angular.module('app', ['ui.bootstrap.dialog'])
.factory('apiModal', function ($http, $q) {
return {
// Открываем модальное окно
openWindow: function ($scope, $dialog, $window, apiModal) {
$scope.test = {name: 'OK'};
var options = {
backdrop: true,
keyboard: true,
controller: 'dialogModal',
template: ':{{test.name}}',
//templateUrl: 'view.html',
};
var dialog = $dialog.dialog(options);
dialog.open().then(function(result) {
if (result === 1) {
apiModal.request();
}
});
},
// Запрос на сервер
request: function (data) {
alert('Отправляем данные с помощью AJAX');
return false;
}
}
})
.controller('Ctrl', function ($scope, $dialog, $window, apiModal) {
// Открываем модальное окно
$scope.openWindow = function() {
apiModal.openWindow($scope, $dialog, $window, apiModal);
};
})
.controller('dialogModal', function($scope, dialog) {
$scope.close = function(result) {
dialog.close(result);
};
});
$scope.test = {name: 'OK'};
{{test.name}}
Answer the question
In order to leave comments, you need to log in
Tell me, are the quotes in your code in the same sequence?
template: ':{{test.name}}',
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question