Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
refactor(subheader): switch to use ng-transclude instead of custom li…
Browse files Browse the repository at this point in the history
…nkingFn
  • Loading branch information
rschmukler committed Sep 24, 2014
1 parent dfa5678 commit e866e69
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/subheader/demos/basic/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

<div ng-app="app" ng-controller="AppCtrl" layout="vertical" flex layout-fill>
<div ng-app="app" ng-controller="SubheaderAppCtrl" layout="vertical" flex layout-fill>
<material-content style="height: 600px;">
<section>
<material-subheader class="material-subheader-colored">Unread Messages</material-subheader>
Expand Down
2 changes: 1 addition & 1 deletion src/components/subheader/demos/basic/script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

angular.module('app', ['ngMaterial'])

.controller('AppCtrl', function($scope) {
.controller('SubheaderAppCtrl', function($scope) {
$scope.messages = [
{
face : '/img/list/60.jpeg',
Expand Down
10 changes: 3 additions & 7 deletions src/components/subheader/subheader.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ angular.module('material.components.subheader', [
function materialSubheaderDirective($compile) {
return {
restrict: 'E',
link: function(scope, $el, $attr) {
var element = angular.element('<h2 material-sticky class="material-subheader ' + $attr.class + '">')
.append($el.contents());

$el.replaceWith(element);
element = $compile(element)(scope);
}
replace: true,
transclude: true,
template: '<h2 material-sticky class="material-subheader"><ng-transclude></h2>'
};
}
2 changes: 1 addition & 1 deletion src/components/subheader/subheader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('materialSubheader', function() {
var $el = $compile('<div><material-subheader>Hello {{ to }}!</material-subheader></div>')($scope);
$scope.$digest();
var $subHeader = $el.children();
expect($subHeader.html()).toEqual('Hello world!');
expect($subHeader.text()).toEqual('Hello world!');
}));

it('should implement $materialSticky', inject(function($compile, $rootScope) {
Expand Down

0 comments on commit e866e69

Please sign in to comment.