i wish to use angular in rails mounted engine. now what i added:
in master applications:
ng-appto the main html tagangular.jsfile inassets/javascript
in the rails mounted engine:
div ng-controller="Ctrl"with{{ title }}var app = angular.module('app', []).controller('Ctrl', function($scope) { $scope.title = "42"; });
now what i got is:
instead of
42i see{{title}}when i
console.log(angular)i see its definedif instead of
ng-appin master application i useangular.bootstrapit doesn't workif i do
angular.bootstrapafter 5 seconds, it works (tried document.ready, doesn't help)
now most how'tos i saw either were not complete or required a lot of dependencies and refactoring and i hope it can be done faster.
ng-app="app"? because you should define a name.$scope:.controller('Ctrl', ['$scope', function($scope) { $scope.title = "42"; })];'use strict';at the start of js file is recommended by ng docs, but i don't think it affects.