js-ngpush

1.0.1 • Public • Published

ngPush

Browserify Build Status David DM

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

Package Sidebar

Install

npm i js-ngpush

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • yunghwakwon