Skip to content

Instantly share code, notes, and snippets.

@mrtnbroder
Created March 31, 2014 10:51
Show Gist options
  • Save mrtnbroder/9889774 to your computer and use it in GitHub Desktop.
Save mrtnbroder/9889774 to your computer and use it in GitHub Desktop.
<div ng-include src="templateBasedOnWidth"></div>
# 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