У меня есть приложение на Angular 1.5.6 . В нем есть контроллер который отдает в вид список песен(да-да говнокод ещё тот :) ).
angular.module("demo").controller("SimpleDemoController", ['$scope', function($scope, $http) {
$scope.models = {
selected: null,
lists: {"Playlist": [
{
"id": 1,
"label": "98 Degrees - Christmas Wish"
},
{
"id":2,
"label": "Anne Shelton - Merry Christmas"
},
{
"id":3,
"label": "Bon Jovi - I Wish Everyday Could Be Like Christmas"
},
{
"id":4,
"label": "Celine Dion - Don't Save It All For Christmas Day"
},
{
"id":5,
"label": "Chris Isaak - Let It Snow"
},
{
"id":6,
"label": "Chris de Burgh - On A Christmas Night"
},
{
"id": 7,
"label": "Christina Aguilera - These Are Special Times"
},
{
"id": 8,
"label": "Christina Perri - Happy Xmas (War Is Over)"
},
{
"id": 9,
"label": "Colbie Caillat - Have Yourself A Merry Little Christmas"
},
{
"id": 10,
"label": "Darius Rucker - Candy Cane Christmas"
},
{
"id":11,
"label": "Dean Martin - White Christmas"
},
{
"id": 12,
"label": "Diana Krall - Christmas Time Is Here"
},
{
"id": 13,
"label": "Diana Ross - Let It Snow! Let It Snow! Let It Snow!"
},
{
"id": 14,
"label": "Elvis Presley - Silver Bells"
},
{
"id": 15,
"label": "Enya - We Wish You A Merry Christmas"
},
{
"id": 16,
"label": "Frank Sinatra - Jingle Bells"
},
{
"id": 17,
"label": "Glen Campbell - Ill Be Home For Christmas"
},
{
"id": 18,
"label": "Justin Bieber - Mistletoe"
},
{
"id": 19,
"label": "Leona Lewis - One More Sleep"
},
{
"id": 20,
"label": "Mary J Blige - When You Wish Upon A Star"
},
{
"id": 21,
"label": "Michael Buble - Let It Snow"
},
{
"id": 22,
"label": "Nat King Cole - Caroling, Caroling"
},
{
"id": 23,
"label": "Pat Boone - Silver Bells"
},
{
"id": 24,
"label": "Paul McCartney - The Christmas Song"
},
{
"id": 25,
"label": "Perry Como - Magic Moments"
},
{
"id": 26,
"label": "Rod Stewart - Let It Snow! Let It Snow! Let It Snow!"
},
{
"id": 27,
"label": "Rosemary Clooney - Winter Wonderland"
},
{
"id": 28,
"label": "Sarah Connor - Christmas In My Heart"
},
{
"id": 29,
"label": "The Manhattan Transfer - A Christmas Love Song"
},
{
"id": 30,
"label": "Toni Braxton Babyface - Have Yourself A Merry Little Christmas"
}
],
"UserSongs": []}
};
$scope.$watch('models', function(model) {
$scope.userPlayList = [];
$scope.modelAsJson = angular.toJson(model, true);
if ($scope.models.lists.UserSongs.length === 10) {
console.log('10 песен выбрано');
$scope.userPlayList = $scope.models.lists.UserSongs;
console.log($scope.userPlayList);
$scope.userPlayList = $scope.models.lists.Playlist;
var list_of_song = $scope.models.lists.UserSongs;
// магия аякса в ангуляре
// $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
$http.post('https://www.radiorelax.ua/special/newyear/data/', {list_of_song})
.success(function (data) {
console.log('done');
console.log(data);
angular.element('.submit-button-send')[0].disabled = false;
})
.error(function (error) {
console.log('error');
});
}
if($scope.models.lists.UserSongs.length === 11){
var deleted_song = $scope.models.lists.UserSongs.pop();
$scope.models.lists.Playlist.push(deleted_song);
}
}, true);
}]);
Собственно сам вид (simple.html):
<ul dnd-list="list">
<li ng-repeat="item in list"
dnd-draggable="item"
dnd-moved="list.splice($index, 1)"
dnd-effect-allowed="move"
dnd-selected="models.selected = item"
ng-class="{'selected': models.selected === item}">
<span class="badge">{{item.id}}</span>
{{item.label}}
</li>
</ul>
и модуль приложения:
<div ng-app="demo">
<div class="block-center">
<div ng-view></div>
</div>
</div>
Так всё работает, но мне нужно дописать функцию которая будет показывать модальное окно вот собственно она:
$scope.videos = function () {
$ngConfirm({
content: '<p></p> ' +
'<div class="embed-responsive embed-responsive-16by9">' +
'<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/3Wv-JIpAjks">' +
'</iframe>' +
'</div>',
theme: 'seamless',
icon: 'fa fa-check-circle-o',
buttons: {
white: {
text: 'Increase size',
btnClass: 'btn-green',
action: function (scope, button) {
this.setColumnClass('medium');
button.setDisabled(true);
return false;
}
},
close: function () {
},
},
onOpen: function (scope) {
scope.data = this;
}
});
};
Для того что бы функция начала работать нужно добавить зависимость в контроллер и переписать его так:
angular.module("demo", ["cp.ngConfirm"]).controller('SimpleDemoController', ['$scope',function ($scope, $ngConfirm) {
//код
}
Но когда добавляю зависимость cp.ngConfirm
перестаёт всё работать. В чем может быть причина?
Кофе для программистов: как напиток влияет на продуктивность кодеров?
Рекламные вывески: как привлечь внимание и увеличить продажи
Стратегії та тренди в SMM - Технології, що формують майбутнє сьогодні
Выделенный сервер, что это, для чего нужен и какие характеристики важны?
Современные решения для бизнеса: как облачные и виртуальные технологии меняют рынок
Интересуют примеры реализации сворачивания-разворачивания коробки по её развёртке (CSS, Canvas, SVG), буду очень признателен
Являюсь новичком в деле JS-разработкиОпыт написания работоспособных программ был
Доброго времени суток! Подскажите, плиз, как проще всего наложить текст поверх анимированного gif и отправить его по почте с сервера?