第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用ng-include時(shí)失去范圍

使用ng-include時(shí)失去范圍

使用ng-include時(shí)失去范圍我有這個(gè)模塊路線:var mainModule = angular.module('lpConnect', []).     config(['$routeProvider', function ($routeProvider) {     $routeProvider.         when('/home', {template:'views/home.html', controller:HomeCtrl}).         when('/admin', {template:'views/admin.html', controller:AdminCtrl}).         otherwise({redirectTo:'/connect'});}]);主頁(yè)HTML:<div ng-include src="views.partial1"></div>partial1 HTML:<form ng-submit="addLine()">     <input type="text" ng-model="lineText" size="30" placeholder="Type your message here"></form>HomeCtrl:function HomeCtrl($scope, $location, $window, $http, Common) {     ...     $scope.views = {         partial1:"views/partial1.html"     };     $scope.addLine = function () {         $scope.chat.addLine($scope.lineText);         $scope.lines.push({text:$scope.lineText});         $scope.lineText = "";     };...}在addLine函數(shù)$scope.lineText中undefined,這可以通過(guò)添加ng-controller="HomeCtrl"來(lái)解決partial1.html,但是它會(huì)導(dǎo)致控制器被調(diào)用兩次。我在這里錯(cuò)過(guò)了什么?
查看完整描述

3 回答

?
莫回?zé)o

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊

這是因?yàn)?code>ng-include它創(chuàng)建了一個(gè)新的子范圍,因此$scope.lineText不會(huì)更改。我認(rèn)為這this是指當(dāng)前的范圍,所以this.lineText應(yīng)該設(shè)置。


查看完整回答
反對(duì) 回復(fù) 2019-07-31
  • 3 回答
  • 0 關(guān)注
  • 643 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)