Created
March 31, 2014 10:51
-
-
Save mrtnbroder/9889774 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-include src="templateBasedOnWidth"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple controller that shows a tapped item's data | |
angular.module("controllers") | |
.controller "ProgramsEventsCtrl", ($scope, $templateCache) -> | |
_iPadURL = "/templates/programs.events.ipad.html" | |
_iPhoneURL = "/templates/programs.events.iphone.html" | |
$scope.templateBasedOnWidth = _iPhoneURL | |
$scope.templateIsiPhone = true | |
reloadView = (url) -> | |
$templateCache.remove $scope.templateBasedOnWidth | |
$scope.templateBasedOnWidth = url | |
listenerForTemplateLoading = -> | |
$window = $(window) | |
$width = $window.width() | |
if $width <= 700 | |
# iphone size | |
if $templateIsiPhone is true | |
# it's the iphone template. return false | |
return false | |
else | |
# it's the ipad template. load the iphone one! | |
$templateIsiPhone = true | |
reloadView(_iPhoneURL) | |
else | |
# ipad size | |
if $templateIsiPhone is true | |
# it's the iphone template. load the ipad one! | |
$templateIsiPhone = false | |
reloadView(_iPadURL) | |
else | |
# it's the ipad template. return false | |
return false | |
ionic.Platform.ready -> | |
console.log $templateCache | |
$window = $(window) | |
$width = $window.width() | |
if $width >= 700 | |
$scope.templateBasedOnWidth = _iPadURL | |
$scope.templateIsiPhone = false | |
$window.on "orientationchange", listenerForTemplateLoading | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment