js-ngpush
v1.0.1
Published
Push to ngModel bootstrapper
Downloads
4
Maintainers
Readme
ngPush
Push to ngModel bootstrapper
A simple way to bootstrap collections without making extra XHR calls or embedding JSON data in your HTML.
Install
npm install js-ngpush
Usage
require("angular");
require("js-ngpush");
var m = angular.module("App", [
"ngPush"
]);
m.controller("FilesCtrl", ["$scope", function($scope){
$scope.files = [];
}]);
Data (something to this effect)
files := []File{
{Name: "file1.txt", Size: 123},
{Name: "file2.txt", Size: 456},
}
HTML
<section data-ng-controller="FilesCtrl">
<% range .Files %>
<ng-push ng-model="files" data-name="<% .Name %>" data-size="<% .Size %>"></ng-push>
<% end %>
</section>
Results in
$scope.files = [
{name: "file1.txt", size: "123"},
{name: "file2.txt", size: "456"}
];
License
MIT