Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.

Commit

Permalink
add simple example
Browse files Browse the repository at this point in the history
  • Loading branch information
wvell committed Feb 4, 2017
1 parent ea4b3b5 commit 2a5a6cc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
24 changes: 24 additions & 0 deletions example/example.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"log"

angularjs "github.com/wvell/go-angularjs"
)

func main() {
app := angularjs.NewModule("test", []string{}, nil)
app.NewController("TestCtrl", TestCtrl)

log.Print("running app")
}

func TestCtrl(scope *angularjs.Scope) {
scope.Set("test", "Im a variable that is set on angular's $scope")

ticked := 0
scope.Set("tick", func() {
ticked++
log.Printf("ticking: %d", ticked)
})
}
14 changes: 14 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html ng-app="test">
<head>
<title>My AngularJS App</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script src="http://localhost:8080/github.com/wvell/go-angularjs/example/example.js"></script>
</head>
<body ng-controller="TestCtrl">
{{ test }}

<br /><br />
<button ng-click="tick()">Check your console</button>
</body>
</html>

0 comments on commit 2a5a6cc

Please sign in to comment.