我在这里追我的尾巴。我要做的就是从$ scope.getPlacesTextRaw函数返回一个字符串。
$scope.getPlacesTextRaw = function(selectedPlace){
mentionsFactory.getPlaceMetaData(selectedPlace).then(function(metadata) {
console.log("here is our metadata", metadata);
return metadata.description.replace(/ /g,"_");
});
};
另一次尝试:
$scope.getPlacesTextRaw = function(selectedPlace){
var deferred = $q.defer();
mentionsFactory.getPlaceMetaData(selectedPlace).then(function(metadata) {
console.log("here is our metadata", metadata);
deferred.resolve('@' + metadata.description.replace(/ /g,"_"));
});
deferred.promise.then(function(string){
return string;
});
};
我在指令中调用getPlacesTextRaw:
<mentio-menu
mentio-for="'hashtag'"
mentio-trigger-char="'@'"
mentio-items="places"
mentio-template-url="/places-mentions.tpl"
mentio-search="searchPlaces(term)"
mentio-select="getPlacesTextRaw(item);">
</mentio-menu>
答案 0 :(得分:0)
所以我想:)
请看这里https://docs.angularjs.org/error/$rootScope/infdig?p0=10&p1=%5B%5D
第二块
你有一点改变方法,请看看演示:http://jsbin.com/kakim/2/edit
不过mentio-select="getPlacesTextRaw(item)
做mentio-select="PlacesTextRaw"
$scope.PlacesTextRaw = "";
$scope.getPlacesTextRaw = function (selectedPlace) {
mentionsFactory.getPlaceMetaData(selectedPlace).then(function (metadata) {
console.log("here is our metadata", metadata);
$scope.PlacesTextRaw = metadata.description.replace(/ /g, "_");
});
};
$scope.item = "test"
function activate() {
$scope.getPlacesTextRaw($scope.item);
}
activate();
答案 1 :(得分:0)
ment.io团队更新了他们的产品以支持承诺。活泉!