polecam korzystania Ng2-Dragula.
Jest to zależność angular2, która zapewnia łatwą funkcję przeciągania i upuszczania do aplikacji.
Wszystko, co musisz zrobić, to zainstalować tę zależność przez npm.
npm install ng2-dragula dragula --save
dodatek zawiera wewnątrz index.html i układ skonfigurować jako
<script src="/node_modules/ng2-dragula/bundles/ng2-dragula.js"></script>
<link href="/node_modules/ng2-dragula/src/public/css/dragula.min.css" rel='stylesheet' type='text/css'>
<script>
System.config({
paths:{
'dragula' : '../node_modules/dragula/dist/dragula.min.js'
},
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/main')
.then(null, console.error.bind(console));
</script>
importu go wewnątrz elementu, w którym chcesz używać drag n drop i jesteś dobry, aby przejść.
@Component({
selector: 'sample',
directives: [Dragula],
viewProviders: [DragulaService],
template:`
<div>
<div class='wrapper'>
<div class='container' [dragula]='"first-bag"'>
<div>You can move these elements between these two containers</div>
<div>Moving them anywhere else isn't quite possible</div>
<div>There's also the possibility of moving elements around in the same container, changing their position</div>
</div>
<div class='container' [dragula]='"first-bag"'>
<div>This is the default use case. You only need to specify the containers you want to use</div>
<div>More interactive use cases lie ahead</div>
<div>Make sure to check out the <a href='https://github.com/bevacqua/dragula#readme'>documentation on GitHub!</a></div>
</div>
</div>
</div>
`
})
class Sample {}
Uświadomiłem sobie, że zapomniałem dodać dyrektywę do listy dyrektyw komponentów. Chociaż wydaje się, że metoda .toRx na EventEmitter nie jest już dostępna. Jak to zmienić? – theva
Od wersji Beta 1 [nie trzeba już wywoływać funkcji .toRx() w emulatorze] (http://stackoverflow.com/questions/33530726/wymiarowym-2-niepodwójnym-rozsyłaniu-następnie-z-urządzeniem- funkcja/33534404 # 33534404). –
jest całkiem niezły opis tutaj http://stackoverflow.com/a/38710223/2173016 –