Skip to content

Commit

Permalink
feat: add @controller支持
Browse files Browse the repository at this point in the history
  • Loading branch information
dongchongyang committed Sep 21, 2017
1 parent ca3a934 commit d7b382f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
17 changes: 5 additions & 12 deletions dist/onion.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ var Observable = function Observable() {
}

return function (target, name, descriptor) {
// options 1. expression, 2. deep, 3. method(optional watch, watchGroup..etc)
var watchMethod = '$watch';
var watchUtilMethod = ['$watch', '$watchCollection', '$watchGroup'];

Expand All @@ -496,17 +495,8 @@ var Observable = function Observable() {
throw new SyntaxError('@Observable() method ' + name + ' only support ' + watchUtilMethod.join('、') + ' method;');
}

// $$Observable Watch 的队列
target.$$Observable || (target.$$Observable = []);

// 为什么判断 undefined. 因为babel转码会把es module的this转化为 undefined; 并且格式化
if (typeof expression !== 'string' && expression.toString().includes('undefined.')) {
var line = expression.toString().split('\n').filter(function (line) {
return line.includes('return');
})[0];
expression = line.toString().replace('return', '').replace('undefined.', '$ctrl.');
}

var observe = {
method: watchMethod,
expression: expression,
Expand Down Expand Up @@ -567,8 +557,6 @@ var Component = function Component(options) {
controller: target,
bindings: props
};

angular.module = angular.module;
};
};

Expand Down Expand Up @@ -630,6 +618,11 @@ function resetModule() {
var _controller2 = extendInfo.controller;

this.service(_name, _controller2);
} else if (extendInfo.type === 'controller') {
var _controller3 = extendInfo.controller,
_name2 = extendInfo.name;

this.controller(_name2, _controller3);
}
};
return result;
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
]
],
"_from": "angular-onion@latest",
"_id": "[email protected].0",
"_id": "[email protected].1",
"_inCache": true,
"_location": "/angular-onion",
"_nodeVersion": "6.10.2",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/angular-onion-8.2.0.tgz_1505111756445_0.607928388286382"
"tmp": "tmp/angular-onion-8.2.1.tgz_1505111756445_0.607928388286382"
},
"_npmUser": {
"name": "onion3",
Expand All @@ -40,7 +40,7 @@
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/angular-onion/-/angular-onion-8.2.0.tgz",
"_resolved": "https://registry.npmjs.org/angular-onion/-/angular-onion-8.2.1.tgz",
"_shasum": "f2fd94a2f92615e2384e5ac77c520646d54b803c",
"_shrinkwrap": null,
"_spec": "angular-onion",
Expand All @@ -61,7 +61,7 @@
"directories": {},
"dist": {
"shasum": "f2fd94a2f92615e2384e5ac77c520646d54b803c",
"tarball": "https://registry.npmjs.org/angular-onion/-/angular-onion-8.2.0.tgz"
"tarball": "https://registry.npmjs.org/angular-onion/-/angular-onion-8.2.1.tgz"
},
"license": "MIT",
"main": "dist/onion.js",
Expand All @@ -78,5 +78,5 @@
"build": "webpack --config webpack.config.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "8.2.0"
"version": "8.2.1"
}

0 comments on commit d7b382f

Please sign in to comment.