Javascript 流星角指令
上周早些时候,我偶然发现了一个非常有趣的发现,“角流星”。允许使用AngularJS框架的Meteor包。考虑到我有一些多余的空闲时间,比如假期等等,我决定尝试一下 我已经为我的web应用程序编写了逻辑基础,但仍然存在一个非常令人困惑的问题。无论出于何种原因,脚本之外与应用程序实例化相关的所有角度函数都不起作用 client/index.html client/app/shared/layout/directive.js 结果Javascript 流星角指令,javascript,angularjs,meteor,angular-meteor,Javascript,Angularjs,Meteor,Angular Meteor,上周早些时候,我偶然发现了一个非常有趣的发现,“角流星”。允许使用AngularJS框架的Meteor包。考虑到我有一些多余的空闲时间,比如假期等等,我决定尝试一下 我已经为我的web应用程序编写了逻辑基础,但仍然存在一个非常令人困惑的问题。无论出于何种原因,脚本之外与应用程序实例化相关的所有角度函数都不起作用 client/index.html client/app/shared/layout/directive.js 结果 测试#1(通过) 测试#2(通过) 测试#3(失败) 测试4(失败
- 测试#1(通过)
- 测试#2(通过)
- 测试#3(失败)
- 测试4(失败)
<body ng-app="aboutjn"
ng-controller="mainCtrl">
<stdLayout></stdLayout>
</body>
angular.module('aboutjn',['angular-meteor']); // # initialize angular module
/*
* ANGULAR-METEOR CHEAT-SHEET
* @ newbie guide
$root.currentUser =>
*/
angular.module('aboutjn')
.controller('mainCtrl', ['$scope', '$reactive', function ($scope, $reactive) {
$reactive(this).attach($scope);
// create reactive context within scope
$scope.helpers({
posts: function() {
return Posts.find({}, {sort: {createdAt: -1}})
}
}); // meteor style helper to instantiate scope context
console.log('test #1'); // # passed
}]);
console.log('test #2'); // # passed
var module = angular.module('aboutjn');
module.run(function() {
console.log('test #3'); // # failed
});
module.directive('std-layout', function() {
return {
restrict: 'E',
templateUrl: 'client/app/shared/layout/view/stdLayout.html',
controllerAs: 'layoutCtrl',
controller: function () {
console.log('test #4'); // # failed
}
};
});