This example compiles with :optimizations :advanced.
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
(ns gameapp) | |
(def gamemod | |
"Create a gameapp module within Angular.js" | |
(.module js/angular "gameapp" (array))) | |
(.directive gamemod "gameslist" | |
(fn [] | |
(js-obj | |
"restrict" "E" | |
"scope" (js-obj "games" "=") | |
"template" "<div ng-repeat='game in games'>Game {{game.name}}</div>" | |
))) | |
(defn ^:export GameCtrl [$scope] | |
(aset $scope "mygames" (array | |
(js-obj "name" "a") | |
(js-obj "name" "b") | |
(js-obj "name" "c")))) | |
(aset GameCtrl "$inject" (array "$scope")) |
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
<!doctype html> | |
<html ng-app="gameapp"> | |
<head> | |
<script src="angular.min.js"></script> | |
<script src="cljs-w-directive.js"></script> | |
</head> | |
<body> | |
<h2>Game names</h2> | |
<div ng-controller="gameapp.GameCtrl"> | |
<gameslist games="mygames"/> | |
</div> | |
</body> | |
</html> |