我拼命尝试将一个简单的字符串传递给 AngularJS 组件,我有以下 angularJS 组件:
async-typeahead.componenet.js:
angular.module('asyncTypeahead').component('asyncTypeahead', {
templateUrl: 'static/partials/async-typeahead/async-typeahead.template.html',
bindings: {
pk: '=',
object: '=',
objectType: '@'
},
controller: ['$scope','$http',
function AsyncTypeaheadController($scope, $http) {
var self = this;
self.getTags = function (val) {
console.log("async-typeahead input is: " +val);
console.log("async-typeahead object keys are: " + angular.toJson(self.object));
console.log("async-typeahead type is: " + angular.toJson(self.objectType));...
并按照 html 调用组件:
<async-typeahead object="$ctrl.actor.actor_tags" objectType={{ This is just a string }}></async-typeahead>
'val' 只是来自预输入的输入。
我已经尝试过objectType={{ This is just a string }}
, objectType="This is just a string"
并且objectType=This is just a string
我还尝试将绑定从 '=' 更改为 '@' 或 '>' 结果是一样的:
每当我查看控制台时,我总是会得到:
异步预输入输入为:df
异步预输入对象 kes 是:[37,43,49]
async-typeahead 类型为:未定义
我究竟做错了什么?如何将简单的字符串传递给 angularJS 组件?