I am making an application with Ionic and I want to have a square image as the background. The image needs to be scaled for different resolutions; I want it to fill the width of the device, and then be so tall that it has such a width while maintaining the aspect ratio.
I tried to add a directive to calculate the correct height for the installation, but I can not get it to do anything, it does not seem to be called at all.
HTML
<ion-view view-title="Home" > <ion-content class > <div id = "card" ng-model = "card"> <h3>{{card.name}}</h3> </div> </ion-content> </ion-view>
CSS
#card{ background-image: url("/img/education.png"); background-size: 100% 100%; width : 100%; }
Javascript (controllers.js)
.directive("card", function($scope) { console.log("Card directive called."); return { restrict: "E", link: function (scope, element) { console.log("Link Called"); element.height = element.width; } } })
source share