Demo entry 1869902

An Angular.js app in ClojureScript


Submitted by anonymous on Jun 09, 2015 at 02:10
Language: ClojureScript. Code size: 754 Bytes.

(ns acute.tutorial.controllers
  (:require [cljs.reader :refer [read-string]]
            [acute :refer [angular]]))

; memo - would be great to wrap these aset/aget calls in something
; but for now that's not my main focus

(defn PhoneListController [$scope, $http]
  (-> $http (.get "phones/phones.edn")
      (fn [data]
        (aset $scope "phones" data))))
  (aset $scope "orderProp" "age"))

(defn PhoneDetailController [$scope, $routeParams, $http]
  (-> $http (.get (str "phones/" (aget $routeParams "phoneId") ".edn"))
      (fn [data]
        (aset $scope "phone" data)
        (aset $scope "mainImageUrl" (first (:images data))))))
  (aset $scope "setImage" #(aset $scope "mainImageUrl" %)))

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).