Javascript Angularjs将简单字符串传递给组件
我拼命地想把一个简单的字符串传递给AngularJS组件, 我有以下angularJS组件:Javascript Angularjs将简单字符串传递给组件,javascript,angularjs,angularjs-components,Javascript,Angularjs,Angularjs Components,我拼命地想把一个简单的字符串传递给AngularJS组件, 我有以下angularJS组件: <async-typeahead object="$ctrl.actor.actor_tags" objectType={{ This is just a string }}></async-typeahead> 异步typeahead.componenet.js: angular.module('asyncTypeahead').component('as
<async-typeahead object="$ctrl.actor.actor_tags" objectType={{ This is just a string }}></async-typeahead>
异步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”只是来自typeahead的输入
我尝试了objectType={{这只是一个字符串}
和objectType=“这只是一个字符串”
和objectType=这只是一个字符串
我还尝试了将绑定从“=”更改为“@”或“>”,结果相同:
每当我看到控制台时,我总是得到:
异步typeahead输入为:df
异步typeahead对象是:[37,43,49]
异步typeahead类型为:未定义
我做错了什么?如何将简单字符串传递给angularJS组件?关于html中使用的objectType属性的问题。指令/组件名称及其所有属性应以“-”分隔 正确的代码附在下面: