Created
February 23, 2017 10:04
-
-
Save anonymous/c9163cade0ba50450b18c94022bb8146 to your computer and use it in GitHub Desktop.
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
angular.module('mymodule').controller "ItemNewCtrl", ['$scope', '$modal', '$http', 'current_session', ($scope, $modal, $http, current_session)-> | |
$scope.item = current_session.item | |
$scope.submitItem = (data, redirect_url) -> | |
$http.post("/new_item_url", data).success( | |
(send_response)-> | |
window.location.href = redirect_url | |
).error( | |
(r)-> | |
Flashing.setMessage("bad","Error." ) | |
) | |
$scope.create = (item)-> | |
data = { item: item } | |
# CREATING A NEW item | |
$scope.submitItem(data, "/redirect_url") | |
] |
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
<div ng-controller="ItemNewCtrl"> | |
<form ng-submit="create(item);" ng-init="item = <%= @item.to_json %>"> | |
<textarea id="item_description" ng-model="item.description"><%= @item[:description] %></textarea> | |
<input type="hidden" ng-model="item.attribute"> | |
<button type="submit">Submit</button> | |
</form> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment