<commit_before>/**
 * Created by <NAME> on 1/31/14.
 * UI Router version by <NAME> on 2/27/14.
 * http://www.zackboman.com or <EMAIL>
 */

(function(){

    var mod = angular.module('routeStyles', ['ui.router']);

    mod.directive('head', ['$rootScope','$compile',
		function($rootScope, $compile){
			return {
				restrict: 'E',
				link: function(scope, elem){
					var html = '<link rel="stylesheet" ng-repeat="(routeCtrl, cssUrl) in routeStyles" ng-href="{{cssUrl}}" >';
					elem.append($compile(html)(scope));
					scope.routeStyles = {};
					$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
						
						// Remove old styles
						if(fromState && fromState.views){
							angular.forEach(fromState.views, function(view){
								if(view.css){
									if(!Array.isArray(view.css)){
										view.css = [view.css];
									}
									angular.forEach(view.css, function(sheet){
										delete scope.routeStyles[sheet];
									});
								}
							});
						}
						
						// Add new styles
						if(toState && toState.views){
							angular.forEach(toState.views, function(view){
								if(view.css){
									if(!Array.isArray(view.css)){
										view.css = [view.css];
									}
									angular.forEach(view.css, function(sheet){
										scope.routeStyles[sheet] = sheet;
									});
									
								}
							});
						}
					});
				}
			};
		}
	]);

})();
<commit_msg>Fixes #12: States including css are now used<commit_after>/**
 * Created by <NAME> on 1/31/14.
 * UI Router version by <NAME> on 2/27/14.
 * http://www.zackboman.com or <EMAIL>.com
 */

(function(){

    var mod = angular.module('routeStyles', ['ui.router']);

    mod.directive('head', ['$rootScope','$compile',
		function($rootScope, $compile){
			return {
				restrict: 'E',
				link: function(scope, elem){
					var html = '<link rel="stylesheet" ng-repeat="(routeCtrl, cssUrl) in routeStyles" ng-href="{{cssUrl}}" >';
					elem.append($compile(html)(scope));
					scope.routeStyles = {};
					$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
						// Remove old styles
						if (fromState && fromState.css) {
							if(!Array.isArray(fromState.css)){
								fromState.css = [fromState.css];
							}
							angular.forEach(fromState.css, function(sheet){
								delete scope.routeStyles[sheet];
							});
						}
						if(fromState && fromState.views){
							angular.forEach(fromState.views, function(view){
								if(view.css){
									if(!Array.isArray(view.css)){
										view.css = [view.css];
									}
									angular.forEach(view.css, function(sheet){
										delete scope.routeStyles[sheet];
									});
								}
							});
						}
						
						// Add new styles
						if(toState && toState.views){
							angular.forEach(toState.views, function(view){
								if(view.css){
									if(!Array.isArray(view.css)){
										view.css = [view.css];
									}
									angular.forEach(view.css, function(sheet){
										scope.routeStyles[sheet] = sheet;
									});
									
								}
							});
						}
						if (toState && toState.css) {
							if(!Array.isArray(toState.css)){
								toState.css = [toState.css];
							}
							angular.forEach(toState.css, function(sheet){
								scope.routeStyles[sheet] = sheet;
							});
						}
					});
				}
			};
		}
	]);

})();

{'fraction_non_alphanumeric': 0.1695613776861937, 'fraction_numerical': 0.006476302619958787, 'mean_word_length': 2.1668219944082012, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1413125', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1070, 'n_words': 185}