Using AngularJS within Haml views of a Rails app -


i have rails app haml views. want add angularjs parts of application, problem haml views rendered server-side , angularjs code not working, because rendered client-side.

let's have in index.html.haml:

!!! %html{"ng-app" => "test"}   %head     %script{:src => "http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"}     :javascript       function clock($scope) {         $scope.currenttime = new date();       }     %title welcome angularjs   %body     %h1 hello, world.     %p{"ng-controller" => "clock"}       current time {{currenttime | date:'h:mm:ss a'}}. 

so currently, it's printing out within curly brackets without processing it. there solutions situations complete view replaced angularjs template. want use angularjs small bits of functionality in rails app. ideas how solve this?

john,

i have edited code bit here: http://codepen.io/anon/pen/vkiwh

%html{"ng-app"=>true}  %p{"ng-controller" => "clock"}   current time {{currenttime | date:'h:mm:ss a'}}. 

and javascript is:

function clock($scope) {   $scope.currenttime = new date().gettime(); } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -