Last active
September 29, 2015 18:17
-
-
Save fesor/95cccf38abb80d1e193c to your computer and use it in GitHub Desktop.
Example NG
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
import angular from 'angular'; | |
import dxMediaFeed from './media/media_feed.component.js'; | |
export default angular | |
.module('app', []) | |
.config(statesConfig) | |
.name; | |
function statesConfig($stateProvider) { | |
$stateProvider.state('media', { | |
url: '/?q', | |
template: '<dx-media-feed query="params.q"></dx-media-feed>', | |
controller: function ($stateParams) { | |
this.q = $stateParams.q; | |
}, | |
controllerAs: 'params' | |
}) | |
} |
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
import template from './media_feed.jade'; | |
import './media_feed.less'; | |
class MediaFeedController { | |
constructor(mediaRepository) { | |
this.mediaRepository = mediaRepository; | |
this.feed = null; | |
} | |
search(query) { | |
// do some stuff... | |
this.mediaRepository.getMediaFeed(query).then((feed) => { | |
this.feed = feed; | |
}); | |
} | |
} | |
export default function () { | |
return { | |
restrict: 'E', | |
template, | |
scope: { | |
query: '=' | |
}, | |
controller: MediaFeedController, | |
controllerAs: 'vm', | |
link: function (scope, el, attr, ctrl) { | |
scope.$watch('query', (q) => { | |
ctrl.search(query); | |
}); | |
} | |
} | |
} |
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
.media-feed | |
.media-feed__item( | |
ng-repeat="item in vm.feed" | |
) {{ item.id }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment