My MediaService
service is being modified within a component. The data in MediaService
is connected to another component, but any changes made in the first component are not reflected in the HTML of the second component.
MediaService
angular
.module('commons')
.service('MediaService', function () {
this.selectedMedia = {}
this.isPlaying = false
return this;
})
This is where the data is being altered
readerMedias
angular
.module("app")
.component("readerMedias", {
bindings: {
medias: "="
},
templateUrl: "app/reader/components/reader-medias/reader-medias.html",
controller: function (MediaService) {
MediaService.selectedMedia.url = "test" // using a real url
MediaService.selectedMedia.type = "video"
MediaService.isPlaying = true
}
})
The changes are seen in this component through debugging, however, they do not reflect in the component's HTML
readerPlayer
angular
.module('app')
.component('readerPlayer', {
templateUrl: 'app/reader/components/reader-player/reader-player.html',
controllerAs: '$ctrl',
controller: function (MediaService, $scope){
$scope.MediaService = MediaService
console.log(MediaService)
return this;
}
})
readerPlayer HTML
div.playing-media(
ng-draggable
ng-init="$ctrl.isFull = true"
ng-class="{\
'full-media': $ctrl.isFull, \
'min-media': !$ctrl.isFull \
}"
ng-if="MediaService.isPlaying"
)
div.playing-head
div
span.material-icons.full(
ng-click="$ctrl.isFull = !$ctrl.isFull"
) photo_size_select_large
span.material-icons.close(
ng-click="MediaService.isPlaying = false"
) clear
div.content
video(
controls
ng-if="MediaService.selectedMedia.type != audio"
)
source(
ng-src="{{MediaService.selectedMedia.url}}"
type="video/mp4"
)
audio(
ng-if="MediaService.selectedMedia.type == audio"
)
source(
ng-src="{{MediaService.selectedMedia.url}}"
type="audio/mp3"
)