i`m busy on a music store web application with JAVA for back-end and Angular JS/HTML5/CSS3 for front-end.
ammm, and for music play back i used Sound Manager Java Script Library, all thing work fine with static 360 player, but when i try to use sound manager in ng-repeat directive, that not works, any suggestion please ? and is sound manager works with live dom elements created by angular js "ng-repeat" ?
Sound Manager Init
// init Sound Manager
soundManager.setup({
// path to directory containing SM2 SWF
url: 'player/'
});
threeSixtyPlayer.config.scaleFont = (navigator.userAgent.match(/msie/i)?false:true);
threeSixtyPlayer.config.showHMSTime = true;
// enable some spectrum stuffs
threeSixtyPlayer.config.useWaveformData = true;
threeSixtyPlayer.config.useEQData = true;
// enable this in SM2 as well, as needed
if (threeSixtyPlayer.config.useWaveformData) {
soundManager.flash9Options.useWaveformData = true;
}
if (threeSixtyPlayer.config.useEQData) {
soundManager.flash9Options.useEQData = true;
}
if (threeSixtyPlayer.config.usePeakData) {
soundManager.flash9Options.usePeakData = true;
}
if (threeSixtyPlayer.config.useWaveformData || threeSixtyPlayer.flash9Options.useEQData || threeSixtyPlayer.flash9Options.usePeakData) {
// even if HTML5 supports MP3, prefer flash so the visualization features can be used.
soundManager.preferFlash = true;
}
Angular ng-repeat
<div class="mod-contents">
<div class="questions-block" ng-repeat="question in filtered = ( questionList | filter:searchKey | orderBy : predicate : reverse)">
<div class="col-xs-12 col-sm-4 col-md-3 pull-right">
<div class="thumbnail block-black ">
<h3 class="block-title rtl-element">{{ question.description }}<span class="text-muted"> ({{ question.cat_code }}) </span></h3>
<div class="ui360 ui360-vis player-wrapper-md player-md "></div>
</div>
</div>
</div>
</div>
I was having the same problem. I think I know why it's happening. I believe in the javascript for sound manager it looks for instances of a sound manager player and doesn't find any. The ng-repeat section is not static; it can change. So when you load the page and the sound manager loads, the ng-repeat section does not yet contain any elements. Therefore sound manager decides not to add an event handler for checking if you click on the button.
I edited the mp3-player-button.js and in the init section I commented out where it said "if (foundItems>0)" so that it always adds the sound manager event handler.
This solution is a little hacky - so maybe you can implement something smarter. But it works for me. Hope it Helps!
Related
I'm having an issue with ngRepeat :
I want to display a list of students in two different ways. In the first one they are filtered by group, and in the second they are not filtered.
The whole display being quite complex, I use a ngInclude with a template to display each student. I can switch between view by changing bClasseVue, each switch being followed by a $scope.$apply().
<div ng-if="currentCours.classesOfGroup !== undefined"
ng-show="bClassesVue">
<div ng-repeat="group in currentCours.classesOfGroup">
<br>
<h2>Classe : [[group.name]]</h2>
<div class="list-view">
<div class="twelve cell"
ng-repeat="eleve in group.eleves | orderBy:'lastName'"
ng-include="'liste_eleves.html'">
</div>
</div>
</div>
</div>
<div class="list-view" ng-show="!bClassesVue">
<div class="twelve cell"
ng-repeat="eleve in currentCours.eleves.all"
ng-include="'liste_eleves.html'">
</div>
</div>
My problem happens when my list of students change (currentCours here). Instead of refreshing the ngRepeat, both lists concatenate, but only in the unfiltered view.
I tried adding some $scope.$apply in strategic places (and I synchronize my list for example) but it doesn't help.
EDIT : the function used to refresh currentCours in the controller. It's called when a "cours" is selected inside a menu.
$scope.selectCours = function (cours) {
$scope.bClassesVue = false;
$scope.currentCours = cours;
$scope.currentCours.eleves.sync().then(() => {
if ($scope.currentCours.classe.type_groupe === 1) {
let _elevesByGroup = _.groupBy($scope.currentCours.eleves.all, function (oEleve) {
return oEleve.className;
});
$scope.currentCours.classesOfGroup = [];
for(let group in _elevesByGroup) {
$scope.currentCours.classesOfGroup.push({
name: group,
eleves: _elevesByGroup[group]
});
}
$scope.bClassesVue = true;
}
});
utils.safeApply($scope);
};
Well, I found a workaround, but I still don't know why it didn't work, so if someone could write an explanation, I would be very thankful.
My solution was simply to open and close the template each time I switch between views.
Since I have migrated from SystemJS to Webpack(Angular CLI) as the module bundler, my custom google maps makers are not no longer showing but the default ones does, the following is my template:
<sebm-google-map-marker [latitude]="lat" [longitude]="lng"></sebm-google-map-marker>
<sebm-google-map-marker
*ngFor="let nearMovingAgent of nearMovingAgents"
[latitude]="nearMovingAgent.obj.location[1]"
[longitude]="nearMovingAgent.obj.location[0]"
[iconUrl]= "nearMovingAgent.obj.agent_type == 'moving_company'? iconPathMC:iconPathSS" >
<sebm-google-map-info-window>
<h5 class="modal-title" *ngIf="nearMovingAgent.obj.agent_type == 'moving_company'"><small>Moving Company</small></h5>
<h5 class="modal-title" *ngIf="nearMovingAgent.obj.agent_type == 'self_standing'"><small>Self Standing Bakkie/Truck Owner</small></h5>
<hr>
<p>{{nearMovingAgent.obj.address | capitalize }}</p>
<button class="btn view-details" data-toggle="modal" data-target="#myModal" (click)="viewMovingAgentDetail(nearMovingAgent)">View Details</button>
</sebm-google-map-info-window>
</sebm-google-map-marker>
</sebm-google-map>
When i remove the attribute:
[iconUrl]= "nearMovingAgent.obj.agent_type == 'moving_company'? iconPathMC:iconPathSS"
The default icons are shown
And I have the following in my component class:
iconPathMC: string = "../../../images/truck3.png";
iconPathSS: string = "../../../images/pickup.png";
I have tried moving the above statements into ngOnInit() but I still cannot not see the icons on the map even though it throws no errors.
My server (NodeJS, Express and nodemon) shows a status of 200 for request. of the images:
GET /images/truck3.png
GET /images/pickup.png
GET /images/truck3.png 200 19.230 ms - 1347
GET /images/pickup.png 200 20.781 ms - 1347
Do I have to hook into a different component life-cycle to have the icons displayed, can anyone give me an idea of what i am missing.
Thank you.
Well I have solved this by doing this in my component
declare var require: any;
markerIconUrl() {
return require('../../../images/truck3.png')
}
Then called the method 'markerIconUrl' in my template like
<sebm-google-map-marker
*ngFor="let nearMovingAgent of nearMovingAgents"
[iconUrl]="markerIconUrl()"
>
Albeit it solved the issue, I am still on research why it was an issue, it has to do with how Webpack works though.
theres my progress bar code:
<div class="col-sm-4" ng-repeat="var in payloadNbrMissionParStatut">
<h4 class="no-margin">{{var.number}}</h4>
<progressbar value={{tom}} class="progress-xs no-radius no-margin" type={{gg}} ng-if="var.des=='Clos' ? gg='danger' : var.des=='En cours'? gg='warning' :gg='info' " ></progressbar>
{{var.des}}
</div>
the problem is in the value: when i populate it with static data it works good, but when i populate wit data come from the controller it doesnt work.
var is a reserved JS keyword. As errors inside directive expressions are silent, you aren't seeing any alerts because it's simply being ignored. Change var to something else and it should work.
I am trying to create some dynamic html elements in angular based on values I have stored in a SQL database. This is a prize selection application for work where I have 5 prizes which have descriptions associated and each description has a type (span, p, div, h1, etc). So based on what our DB says the line should be i want the html to create itself. The way the data is laid out is I have a data object that has an array of pictures and each picture object has an array of description objects { Pictures[ Descriptions[] ] }
"Pictures":[{"ID":9,"IDName":"messengerBag","Descriptions":[{"ID":7,"Text":"Messenger bag is a perfect size for most 15” laptops. The 10th anniversary logo is beautifully displayed in full detail on the front pocket.","DescriptionType":"h3"},{"ID":8,"Text":"Zippered main compartment includes a padded laptop sleeve.","DescriptionType":"p"},{"ID":9,"Text":"Velcro front pocket with organization panel.","DescriptionType":"p"}, {"ID":10,"Text":"Pen loop and side mesh pocket.","DescriptionType":"p"},{"ID":11,"Text":"Adjustable shoulder strap and two carry handles.","DescriptionType":"ul"},...
I have tried using the values directly and it did not work:
<div ng-repeat="pic2 in vm.data.Pictures" ng-show="{{$index}} == vm.index">
<{{desc.DescriptionType}} ng-repeat="desc in pic2.Descriptions">{{desc.Text}}</{{desc.DescriptionType}}>
</div>
I then decided to try a directive. I could get it to return the text but never the element with the description type i was hoping for.
.directive("dynamicelement", ['$compile', function ($compile) {
return {
restrict: "E",
scope: { desc: '#' },
template: '<' + '{{header}}' + '>' + '{{header2}}' + '</' + '{{header}}' + '>',
controller: function ($scope) {
$scope.header = "p";
$scope.header2 = "hi";
}
}
};
I have read article where they talked about using $compile and needing a link function in my directive but i'm not really sure how to use those.
I also have an example of using ngSwitch from How can I use Angular to output dynamic form fields? but this didn't seem to lend itself to my dual ng-repeat organization I am currently using.
Is what I am trying to accomplish possible and if so anyone have pointers on what I should be looking at? Thanks for your time.
I was able to use ng-if's to solve this. It's not as clean as I had hoped but it is doing the trick.
<div data-ng-repeat="pic2 in vm.data.Pictures" class="picture{{$index}} pictures">
<div data-ng-repeat="desc in pic2.Descriptions">
<p data-ng-if="desc.DescriptionType=='p'">{{desc.Text}}</p>
<span data-ng-if="desc.DescriptionType=='span'">{{desc.Text}}</span>
<div data-ng-if="desc.DescriptionType=='div'">{{desc.Text}}</div>
<label data-ng-if="desc.DescriptionType=='label'">{{desc.Text}}</label>
<h1 data-ng-if="desc.DescriptionType=='h1'">{{desc.Text}}</h1>
<h2 data-ng-if="desc.DescriptionType=='h2'">{{desc.Text}}</h2>
<h3 data-ng-if="desc.DescriptionType=='h3'">{{desc.Text}}</h3>
<h4 data-ng-if="desc.DescriptionType=='h4'">{{desc.Text}}</h4>
<h5 data-ng-if="desc.DescriptionType=='h5'">{{desc.Text}}</h5>
<ul data-ng-if="desc.DescriptionType=='ul'"><li>{{desc.Text}}</li></ul>
<ol data-ng-if="desc.DescriptionType=='ol'"><li>{{desc.Text}}</li></ol>
</div>
</div>
The nested ng-repeat doesn't have any kind of HTML element or directive on it, so there's nothing to repeat.
Something like this should work:
<div ng-repeat="pic2 in vm.data.Pictures" ng-show="{{$index}} == vm.index">
<div ng-repeat="desc in pic2.Descriptions">
{{desc.DescriptionType}}
{{desc.Text}}
</div>
</div>
AngularJS: Alert Popup
<div class="modal-header">
<h3>
<span class="firefinder-match" data-ng-show="dialog.stopOrService === 'STOP'" data-translate-values="{"days":"ALL_DAYS","time":"2015-06-20T08:39:46.654Z","stopOrService":"STOP","stopName":"Fairbairn Av after War Memorial Service [3473]","serviceList":[{"serviceNumber":"910","id":"6350571294206984726","name":"910 City via Majura Business Park(Net14NoAir"}],"selectedService":null,"receiveSituations":false,"processing":false}" data-translate="liveDepartures.alerts.addModal.stopHeader">Add a regular alert for upcoming buses at Fairbairn Av after War Memorial Service [3473]</span>
<span class="firefinder-match ng-hide" data-ng-show="dialog.stopOrService === 'SERVICE'" data-translate-values="{"days":"ALL_DAYS","time":"2015-06-20T08:39:46.654Z","stopOrService":"STOP","stopName":"Fairbairn Av after War Memorial Service [3473]","serviceList":[{"serviceNumber":"910","id":"6350571294206984726","name":"910 City via Majura Business Park(Net14NoAir"}],"selectedService":null,"receiveSituations":false,"processing":false}" data-translate="liveDepartures.alerts.addModal.serviceHeader">Add a regular alert for route </span>
</h3>
</div>
Assertion: Using getText()
var pageHeader = element(by.css('.modal-header > h3 > span'))
expect(pageHeader.getText()).toContain('Add a regular alert');
pageHeader.getText().then(function(text){
console.log("++++++++++++++++++++++++++++++++++++++" +text);
});
Problem: Not able to get text from element
I have tried a number of ways to identify the 'Text' on model header but could not succeed in getting the text from the element. The problem looks like the element is not getting identified. Can someone please help me to resolve this issue.
As the error confirms, your selector is returning both spans within the .modal-header. You could try catching them both and specifying one (Note: I've not tested these):
var pageHeader = $$('.modal-header > h3 > span');
expect(pageHeader.get(0).getText()).toContain('Add a regular alert');
Or try another approach on the selector. Maybe try :not to return only the visible span:
var pageHeader = $('.modal-header span:not(.ng-hide)');
As the warning says, you have multiple elements (an array) found by the locator, so get(n) will be needed. you can wait until the getText() promise to resolve, and finally go for assert/expect.
var spansInPageHeader = element.all(by.css('.modal-header > h3 > span'));
spansInPageHeader.get(1).getText().then(function(text){
expect(text).toContain('Add a regular alert');
});