mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-22 07:58:20 -05:00
Statically get access to the Angular scope
This commit is contained in:
parent
1911f3128a
commit
799091b6e4
@ -2,7 +2,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<script type="text/javascript" src="file:///android_asset/dist/book-bundle.js"></script>
|
<script type="text/javascript" src="file:///android_asset/dist/book-bundle.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body ng-controller="BookCtrl">
|
<body ng-controller="BookCtrl" id="bookController">
|
||||||
<div ng-repeat="verse in verses">
|
<div ng-repeat="verse in verses">
|
||||||
{{ verse.text }}
|
{{ verse.text }}
|
||||||
</div>
|
</div>
|
||||||
|
11
app/src/main/assets/dist/book-bundle.js
vendored
11
app/src/main/assets/dist/book-bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -1,3 +1,4 @@
|
|||||||
|
require 'jquery' # For using selectors to access scope
|
||||||
require 'angular'
|
require 'angular'
|
||||||
|
|
||||||
app = angular.module('bookApp', [])
|
app = angular.module('bookApp', [])
|
||||||
@ -6,4 +7,15 @@ app.controller 'BookCtrl', ['$scope', ($scope) ->
|
|||||||
$scope.verses = [
|
$scope.verses = [
|
||||||
{'text': 'hello.'}
|
{'text': 'hello.'}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$scope.alert = ->
|
||||||
|
alert "Hello!"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
###
|
||||||
|
Future reference: Get the controller scope like so:
|
||||||
|
angular.element($("<controller-element>")).scope().<function>
|
||||||
|
|
||||||
|
For example:
|
||||||
|
angular.element($("#bookController")).scope().<function>
|
||||||
|
###
|
||||||
|
Loading…
Reference in New Issue
Block a user