我正在跨多个控制器共享服务。我做了这个简化的小提琴来说明它:http: //jsfiddle.net/ziaxdk/FFgpX/
app.service("common", function() {
var first = 1, second = 2;
return {
first: first,
second: second,
// {{model.first+model.second}} calculate this down here??
calc: function() { return first + second; } // This line is not watched
}
});
如何在服务对象上创建计算规则/属性,以便它们反映到视图中?
问候,
肯尼斯